-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Conversation
Signed-off-by: Alexander Falkenstern <[email protected]>
Signed-off-by: Florian Binder <[email protected]>
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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()
.
There was a problem hiding this comment.
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
} catch (IOException exception) { | ||
} finally { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
<parameter name="family" type="text"> | ||
<label>IRobot Family</label> | ||
<description>IRobot device family</description> |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
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!
Hi @fwolter , |
remove unused parameters Signed-off-by: Florian Binder <[email protected]>
There was a problem hiding this 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!
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
…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]>
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:
Signed-off-by: Florian Binder [email protected]