-
-
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
[shelly] Add support for Shelly BLU Gateway Gen3 #18174
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Markus Michels <[email protected]>
Signed-off-by: Markus Michels <[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.
Ultra minor comment.
This PR not only adds support for new device it also changes de date time handling.
@@ -1607,6 +1609,7 @@ See notes on discovery of Shelly BLU devices above. | |||
| battery | batteryLevel | Number | yes | Battery Level in % | | |||
| | lowBattery | Switch | yes | Low battery alert (< 20%) | | |||
|
|||
|
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 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.
correct, I could if required create another PR
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 would be best, thanks!
Will this also support BLU TRVs? |
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.
A few comments.
@@ -304,13 +304,17 @@ public static DateTimeType getTimestamp(String zone, long timestamp) { | |||
ZoneId zoneId = !zone.isEmpty() ? ZoneId.of(zone) : ZoneId.systemDefault(); | |||
ZonedDateTime zdt = LocalDateTime.now().atZone(zoneId); | |||
int delta = zdt.getOffset().getTotalSeconds(); | |||
return new DateTimeType(Instant.ofEpochSecond(timestamp - delta)); | |||
return new DateTimeType(ZonedDateTime.ofInstant(Instant.ofEpochSecond(timestamp - delta), zoneId)); |
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.
@@ -345,7 +345,7 @@ private void addAttribute(Map<String, String> properties, ShellyManagerInterface | |||
value = dateTimeState.format(null).replace('T', ' ').replace('-', '/'); | |||
break; | |||
default: | |||
value = dateTimeState.format(null).replace('T', ' ').replace('-', '/'); | |||
value = getTimestamp(dateTimeState); |
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 this change here, but not in line 345? What is the desired format, do you actually want to use DateTimeType
for formatting (openHAB), or ZonedDateTime
(Java)?
In any case, not related to adding new device support, and looks like a half overwrite of 03a0993.
Adds a new device