Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[irobot] Fix password discovery and command sending for Roomba I-Models. (using gson) #10860

Merged
merged 3 commits into from
Jun 18, 2021
Merged

Conversation

rimago
Copy link
Contributor

@rimago rimago commented Jun 13, 2021

Hello everybody,

this PR is the successor of #10592 and brings the fix of @falkena. I have added a commit to use gson instead of json-path to make it compatible to the openhab requirements.

The original description of the old PR:

this PR fixes password discovery for iRobot Roomba I-Series. Additionally, the regression introduced in
openhab/openhab-core#2208 is fixed. User has reported, that password
fetching works for iRobot Braava m-series mopping robots (https://community.openhab.org/t/irobot-9xx-on-openhab/17774/245). Sadly there is breaking change in robot configuration. I need it, since different robots report different features. I plan to raise more refactoring and feature extending PR's . Additionally this PR fixes #10116. Credit for the fix goes to @J-N-K (@J-N-K I hope, you are fine with. If not, please, ping me i'll revert the change)

Signed-off-by: Florian Binder [email protected]

Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great that you did a follow up! Doesn't look too bad with GSON...

There are some checkstyle warnings left. You could take a look at target/code-analysis/report.html.

IRobotConfiguration config = getConfigAs(IRobotConfiguration.class);

try {
InetAddress.getByName(config.getAddress());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialize() must return fast. This can block if the network fails. You could use scheduler to execute the lookup in a task.

Or can this be removed at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

logger.warn("Failed to parse JSON message from {}: {}", config.ipaddress, e.toString());
logger.warn("Raw contents: {}", payload);
} catch (JsonParseException exception) {
IRobotConfiguration config = getConfigAs(IRobotConfiguration.class);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the configuration read again here? Actually it should be sufficient to read it once in initialize().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed usage of config. Using Thing UID instead

Comment on lines 67 to 68
} catch (IOException exception) {
} finally {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could add a comment, why this exception is ignored.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed catch-block, as the exception is handled outside the function anyway

socket.close();
}

Gson gson = new Gson();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make this a static final field to save resources.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 14 to 16
<parameter name="family" type="text">
<label>IRobot Family</label>
<description>IRobot device family</description>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I see correctly this is newly introduced. If you need to differentiate between models, you could define a thing type for each model.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed the parameter family, as it is not yet used. We can add it again as soon as it is needed.

xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0 https://openhab.org/schemas/config-description-1.0.0.xsd">

<config-description uri="thing-type:irobot:thing">
<parameter name="address" type="text">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this renamed from ipaddress to address intentionally? Can this be kept as ipaddress to maintain backward compatibility? Or is there more in this PR which is not backward compatible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know, it was part of a bigger refactoring. For now I changed it back to ipaddress to preserve backward compatibility.
(We can rename it to "address" together with the other refactoring and break the compatibility only once.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good approach!

@rimago
Copy link
Contributor Author

rimago commented Jun 16, 2021

Hi @fwolter ,
thank you very much for your feedback. I have removed all codestyle warnings and addressed your comments above.

remove unused parameters

Signed-off-by: Florian Binder <[email protected]>
@rimago rimago requested a review from fwolter June 17, 2021 09:52
Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thanks for taking this over!

@fwolter fwolter merged commit 1630430 into openhab:main Jun 18, 2021
@fwolter fwolter added the bug An unexpected problem or unintended behavior of an add-on label Jun 18, 2021
@fwolter fwolter added this to the 3.1 milestone Jun 18, 2021
@rimago rimago deleted the falkenas_fix branch June 18, 2021 09:03
computergeek1507 pushed a commit to computergeek1507/openhab-addons that referenced this pull request Jul 13, 2021
…ls. (using gson) (openhab#10860)

* Fix password discovery for Roomba I-Models.

Signed-off-by: Alexander Falkenstern <[email protected]>

* [irobot] remove json-path dependency (use gson instead)

Signed-off-by: Florian Binder <[email protected]>

* [irobot] fix checkstyle warnings, preserve backward compatibility, and
remove unused parameters

Signed-off-by: Florian Binder <[email protected]>

Co-authored-by: Alexander Falkenstern <[email protected]>
lucacalcaterra pushed a commit to lucacalcaterra/openhab-addons that referenced this pull request Jul 26, 2021
…ls. (using gson) (openhab#10860)

* Fix password discovery for Roomba I-Models.

Signed-off-by: Alexander Falkenstern <[email protected]>

* [irobot] remove json-path dependency (use gson instead)

Signed-off-by: Florian Binder <[email protected]>

* [irobot] fix checkstyle warnings, preserve backward compatibility, and
remove unused parameters

Signed-off-by: Florian Binder <[email protected]>

Co-authored-by: Alexander Falkenstern <[email protected]>
Signed-off-by: Luca Calcaterra <[email protected]>
lucacalcaterra pushed a commit to lucacalcaterra/openhab-addons that referenced this pull request Jul 26, 2021
…ls. (using gson) (openhab#10860)

* Fix password discovery for Roomba I-Models.

Signed-off-by: Alexander Falkenstern <[email protected]>

* [irobot] remove json-path dependency (use gson instead)

Signed-off-by: Florian Binder <[email protected]>

* [irobot] fix checkstyle warnings, preserve backward compatibility, and
remove unused parameters

Signed-off-by: Florian Binder <[email protected]>

Co-authored-by: Alexander Falkenstern <[email protected]>
Signed-off-by: Luca Calcaterra <[email protected]>
lucacalcaterra pushed a commit to lucacalcaterra/openhab-addons that referenced this pull request Aug 3, 2021
…ls. (using gson) (openhab#10860)

* Fix password discovery for Roomba I-Models.

Signed-off-by: Alexander Falkenstern <[email protected]>

* [irobot] remove json-path dependency (use gson instead)

Signed-off-by: Florian Binder <[email protected]>

* [irobot] fix checkstyle warnings, preserve backward compatibility, and
remove unused parameters

Signed-off-by: Florian Binder <[email protected]>

Co-authored-by: Alexander Falkenstern <[email protected]>
Signed-off-by: Luca Calcaterra <[email protected]>
frederictobiasc pushed a commit to frederictobiasc/openhab-addons that referenced this pull request Oct 26, 2021
…ls. (using gson) (openhab#10860)

* Fix password discovery for Roomba I-Models.

Signed-off-by: Alexander Falkenstern <[email protected]>

* [irobot] remove json-path dependency (use gson instead)

Signed-off-by: Florian Binder <[email protected]>

* [irobot] fix checkstyle warnings, preserve backward compatibility, and
remove unused parameters

Signed-off-by: Florian Binder <[email protected]>

Co-authored-by: Alexander Falkenstern <[email protected]>
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this pull request Nov 7, 2021
…ls. (using gson) (openhab#10860)

* Fix password discovery for Roomba I-Models.

Signed-off-by: Alexander Falkenstern <[email protected]>

* [irobot] remove json-path dependency (use gson instead)

Signed-off-by: Florian Binder <[email protected]>

* [irobot] fix checkstyle warnings, preserve backward compatibility, and
remove unused parameters

Signed-off-by: Florian Binder <[email protected]>

Co-authored-by: Alexander Falkenstern <[email protected]>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
…ls. (using gson) (openhab#10860)

* Fix password discovery for Roomba I-Models.

Signed-off-by: Alexander Falkenstern <[email protected]>

* [irobot] remove json-path dependency (use gson instead)

Signed-off-by: Florian Binder <[email protected]>

* [irobot] fix checkstyle warnings, preserve backward compatibility, and
remove unused parameters

Signed-off-by: Florian Binder <[email protected]>

Co-authored-by: Alexander Falkenstern <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iRobot] Make thing ID persistent
3 participants