-
-
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
[automower] Add planner, calendar and command channels #8802
Conversation
Travis tests were successfulHey @marcinczeczko, |
@maxpg Can you take a look? |
@fwolter Sorry for the delay, pretty busy currently. I try to have a look this weekend... |
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.
Thanks for your contribution. Definitely a major improvement to the binding. Also in the area of documentation.
Unfortunately I am not able to test the changes as my automower has already ended its season...
@@ -89,9 +110,24 @@ public AutomowerHandler(Thing thing) { | |||
|
|||
@Override | |||
public void handleCommand(ChannelUID channelUID, Command command) { | |||
if (command instanceof RefreshType) { | |||
Optional<AutomowerCommand> commandName = AutomowerCommand.fromChannelUID(channelUID); |
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 you don't do anything with the AutomowerCommand in case the command is a refresh I would fetch the command in the else clause of the refresh check...
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.
@marcinczeczko can you comment on this?
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.
Yep, it's a good idea. Will fix that
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.
Good point. Will update
new DateTimeType(ZonedDateTime.ofInstant(errorCodeTimestamp, ZoneId.systemDefault()))); | ||
long errorCodeTimestamp = mower.getAttributes().getMower().getErrorCodeTimestamp(); | ||
if (errorCodeTimestamp == 0L) { | ||
updateState(CHANNEL_STATUS_ERROR_TIMESTAMP, UnDefType.NULL); |
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.
Thanks for fixing the problem with the error timestamp :-)
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.
No problem :)
| mower-status#planner-next-start | DateTime | R | The time for the next auto start. If the mower is charging then the value is the estimated time when it will be leaving the charging station. If the mower is about to start now, the value is NULL. | | ||
| mower-status#planner-override-action | String | R | The action that overrides current planner operation. | | ||
| mower-status#calendar-tasks | String | R | The JSON with the information about Automower planner. | | ||
| mower#start | Number | W | Starts the automower for a duration | |
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.
Cool, I like the new command channels. I tried to also do command channels in my initial contribution but they were rejected. But probably because of the way that I implemented them, they didn't fit well and were more like a workaround because I wanted to use actions.
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.
There are some checkstyle warnings left. You could take a look at target/code-analysis/report.html
.
@@ -89,9 +110,24 @@ public AutomowerHandler(Thing thing) { | |||
|
|||
@Override | |||
public void handleCommand(ChannelUID channelUID, Command command) { | |||
if (command instanceof RefreshType) { | |||
Optional<AutomowerCommand> commandName = AutomowerCommand.fromChannelUID(channelUID); |
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.
@marcinczeczko can you comment on this?
<channels> | ||
<channel id="name" typeId="nameType"/> | ||
<channel id="mode" typeId="modeType"/> | ||
<channel id="activity" typeId="activityType"/> | ||
<channel id="state" typeId="stateType"/> | ||
<channel id="last-update" typeId="lastUpdateType"/> | ||
<channel id="battery" typeId="batteryType"/> | ||
<channel id="error-code" typeId="errorCodeType"/> | ||
<channel id="error-timestamp" typeId="errorTimestampType"/> | ||
</channels> | ||
<channel-groups> | ||
<channel-group id="mower-status" typeId="mowerStatus"/> | ||
<channel-group id="mower" typeId="mowerCommands"/> | ||
</channel-groups> |
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.
The grouping of the Channels makes the binding incompatible with current configurations. That means existing users need to remove their mower Thing, re-add it and adjust their Items configuration. Although this breaking change is allowed during the OH 2.5.x -> 3.0.0 release, I think it would annoy users. Is this change really worth it?
Adding new Channels without touching existing ones is okay.
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.
Thanks for that comment. I absolutely agree with that. Will update it accordingly
bundles/org.openhab.binding.automower/src/main/resources/OH-INF/thing/thing-types.xml
Outdated
Show resolved
Hide resolved
@marcinczeczko What is the status of this PR? |
@fwolter - Sorry for not responding for long time. Lot of things were happening on my side that simple blocked myself from any contributions. But fortunately it's getting calm now and I plan to resurrect my PR |
baaf89b
to
b036272
Compare
I addressed all review comments in the latest commit. |
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 need to sign-off your commits. See https://www.openhab.org/docs/developer/contributing.html#sign-your-work The necessary commands are listed when you click on "Details" at the DCO check below.
ZonedDateTime gmt = ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneOffset.UTC); | ||
return ZonedDateTime.of(gmt.getYear(), gmt.getMonthValue(), gmt.getDayOfMonth(), gmt.getHour(), gmt.getMinute(), | ||
gmt.getSecond(), gmt.getNano(), ZoneId.systemDefault()); |
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.
The user can set an individual timezone in OH's settings. You can obtain it by injecting TimeZoneProvider
.
ZonedDateTime gmt = ZonedDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneOffset.UTC); | |
return ZonedDateTime.of(gmt.getYear(), gmt.getMonthValue(), gmt.getDayOfMonth(), gmt.getHour(), gmt.getMinute(), | |
gmt.getSecond(), gmt.getNano(), ZoneId.systemDefault()); | |
LocalDateTime local = LocalDateTime.ofInstant(Instant.ofEpochMilli(timestamp), ZoneOffset.UTC); | |
return ZonedDateTime.of(local, timeZoneProvider.getTimeZone()); |
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.
fixed
|
||
<channel-type id="plannerOverrideActionType"> | ||
<item-type>String</item-type> | ||
<label>The override action</label> |
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.
Words in labels should be capitalized (except prepositions and so on). See https://www.openhab.org/docs/developer/bindings/thing-xml.html#formatting-labels-and-descriptions
<label>The override action</label> | |
<label>Override Action</label> |
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.
fixed labels
|
||
<channel-type id="calendarTasksType"> | ||
<item-type>String</item-type> | ||
<label>The information about the planner as JSON</label> |
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.
Labels are expected to be as short as possible. Guideline is 2-3 words with max 20-25 chars. See https://www.openhab.org/docs/developer/bindings/thing-xml.html#formatting-labels-and-descriptions
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
- Added support for the planner and calendar data - Added command channels - Updated docs Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com>
b036272
to
46a057e
Compare
I pushed one more commit with the last changes. |
a831fc7
to
fb14699
Compare
groups. Improved the mower state update: - Cache the last read state from API - Use cached mower state so the items linked will always be up to date without the need to wait for API refresh period. - Use timeZoneProvider to user user set timezone. Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com>
fb14699
to
75303ff
Compare
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 re-request another review when you are finished making all changes. I will get notified, then.
*/ | ||
@NonNullByDefault |
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.
Did you remove this by intention?
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.
I think I did it intentionally that time due to the new class field mowerState
but apparently I forgot to clean it up. Already fixed it.
Sorry I didn't know about re-request option :) |
Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com>
e766641
to
0a3ef6c
Compare
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
* [Automower] Enhanced binding: - Added support for the planner and calendar data - Added command channels - Updated docs Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> * [Automower] Fixed consts with channel ids after removal of channel groups. Improved the mower state update: - Cache the last read state from API - Use cached mower state so the items linked will always be up to date without the need to wait for API refresh period. - Use timeZoneProvider to user user set timezone. Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> * Rolledback NotNullByDefault annotation Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com>
* [Automower] Enhanced binding: - Added support for the planner and calendar data - Added command channels - Updated docs Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> * [Automower] Fixed consts with channel ids after removal of channel groups. Improved the mower state update: - Cache the last read state from API - Use cached mower state so the items linked will always be up to date without the need to wait for API refresh period. - Use timeZoneProvider to user user set timezone. Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> * Rolledback NotNullByDefault annotation Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> Signed-off-by: John Marshall <john.marshall.au@gmail.com>
* [Automower] Enhanced binding: - Added support for the planner and calendar data - Added command channels - Updated docs Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> * [Automower] Fixed consts with channel ids after removal of channel groups. Improved the mower state update: - Cache the last read state from API - Use cached mower state so the items linked will always be up to date without the need to wait for API refresh period. - Use timeZoneProvider to user user set timezone. Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> * Rolledback NotNullByDefault annotation Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com>
* [Automower] Enhanced binding: - Added support for the planner and calendar data - Added command channels - Updated docs Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> * [Automower] Fixed consts with channel ids after removal of channel groups. Improved the mower state update: - Cache the last read state from API - Use cached mower state so the items linked will always be up to date without the need to wait for API refresh period. - Use timeZoneProvider to user user set timezone. Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> * Rolledback NotNullByDefault annotation Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com>
* [Automower] Enhanced binding: - Added support for the planner and calendar data - Added command channels - Updated docs Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> * [Automower] Fixed consts with channel ids after removal of channel groups. Improved the mower state update: - Cache the last read state from API - Use cached mower state so the items linked will always be up to date without the need to wait for API refresh period. - Use timeZoneProvider to user user set timezone. Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com> * Rolledback NotNullByDefault annotation Signed-off-by: Marcin Czeczko <marcin.czeczko@gmail.com>
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/automower-missing-channels/122319/4 |
I'd like to propose couple of improvements to the Automower binding:
- Added support for the planner and calendar data
- Added command channels
- Removed
name
channel- Updated docs
Signed-off-by: Marcin Czeczko marcin.czeczko@gmail.com