themillhousegroup / openhab2-addons

Add-ons for openHAB 2.x
Eclipse Public License 2.0
36 stars 17 forks source link

Bug fix/sp2-3 state #1

Closed FreddyFox closed 5 years ago

FreddyFox commented 5 years ago

Broadlink SP2-3 devices consistently report state OnOffType.OFF. This is due to the state being derived from the variable used to store the status command payload instead of the decrypted payload which is received. Additionally, the SP2-3 devices sends an acknowledgment packet when commanded to change its state. Since this packet is not captured immediately after the command is sent to the device, this packet is buffered and read the next time the status of the device is read. This means the acknowledgement packet is read as a status packet, causing openhab to misinterpret the device's state until this packet is cleared from the buffer and an actual device state packet is read.

This PR fixes both of these problems. Tested and verified on Ubuntu 16.04 and OpenHAB 2.2 (running in docker)

JAR: https://www.dropbox.com/s/iuocwozkz6v8by2/org.openhab.binding.broadlink-2.4.0-SNAPSHOT.jar?dl=0

themillhousegroup commented 5 years ago

This is awesome. Thankyou @FreddyFox !

FreddyFox commented 5 years ago

Hey again. Thanks for merging my fix so quickly! And great work with the binding. I find it really useful :)

Just a heads-up: Several users have reported some weird temperature measurements after sending a command to the RM2 device. I firmly believe this is also caused by not capturing the acknowledgment packet after sending a command. That is, after this:

https://github.com/themillhousegroup/openhab2-addons/blob/master/addons/binding/org.openhab.binding.broadlink/src/main/java/org/openhab/binding/broadlink/handler/BroadlinkRemoteHandler.java#L49

there should also be a receiveDatagram("acknowledgment packet");

NOTE: It might be that the RM1 device does not send an acknowledgment packet! If so, the sendCode-function should probably be explicitly implemented in BroadlinkRemoteModel2Handler.java as well.

Unfortunately I don't have a RM2 device that I can use to test.

Report of the bug: https://community.openhab.org/t/broadlink-binding-for-rmx-a1-spx-and-mp-any-interest/22768/272