A silly mistake on my part. In adding specific support for the RM4 family of devices, I missed one of the many places that need to be modified when you add a new Thing type.
This is one of the long-standing issues I’ve had with this binding that I’d love to take some time to fix, but never get the time. Namely, when adding a new type of device, you need to:
Add a suitably-named Java class (e.g. BroadlinkRemoteModel4Handler) that extends BroadlinkBaseThingHandler and actually does some work (fair enough)
Add an entry to the ModelMapper that maps Broadlink ID codes (that “Device identifying itself as ‘24994’” stuff) to thing types like broadlink:rm4 (fairly reasonable)
Add an entry to the BroadlinkHandlerFactory that can then translate a thing type like broadlink:rm4 to an instance of a BroadlinkRemoteModel4Handler (starting to feel redundant)
Add an entry to BroadlinkBindingConstants so that broadlink:rm4 is only “defined in one place” (except … it’s not, because:)
Add a giant lump of XML to thing-types.xml that actually corresponds to broadlink:rm4 and defines what configuration and parameters it supports ()
The thing is now added, and I’ve added the key and vector. Unfortunately, OpenHAB can’t seem to connect (I have a BestCon branded RM4C Mini). Here’s my log from loading the new jar file:
19:21:42.152 [INFO ] [l.discovery.BroadlinkDiscoveryService] - BroadlinkDiscoveryService - Constructed
19:22:56.044 [WARN ] [l.discovery.BroadlinkDiscoveryService] - BroadlinkDiscoveryService - Beginning Broadlink device scan...
19:22:56.080 [WARN ] [.internal.discovery.DiscoveryProtocol] - Beginning async Broadlink device scan; will wait 10000 ms for responses
19:22:56.133 [WARN ] [.internal.discovery.DiscoveryProtocol] - Broadlink device scan waiting for 10000 ms to complete ...
19:22:56.469 [INFO ] [l.discovery.BroadlinkDiscoveryService] - Data received during Broadlink device discovery: from 192.168.1.117:80 [24:df:a7:4f:7c:e6]
19:22:56.478 [DEBUG] [l.discovery.BroadlinkDiscoveryService] - Adding new Broadlink device on 192.168.1.117 with mac '24:df:a7:4f:7c:e6' to Smarthome inbox
19:22:56.488 [DEBUG] [l.discovery.BroadlinkDiscoveryService] - Device 'broadlink:rm4:24-df-a7-4f-7c-e6' discovered at '192.168.1.117'.
19:22:56.500 [INFO ] [ig.discovery.internal.PersistentInbox] - Added new thing 'broadlink:rm4:24-df-a7-4f-7c-e6' to inbox.
19:23:05.634 [DEBUG] [link.internal.BroadlinkHandlerFactory] - Creating Thing handler for 'broadlink:rm4'
19:23:05.645 [DEBUG] [link.internal.BroadlinkHandlerFactory] - RM 4 handler requested created
19:23:06.181 [WARN ] [.internal.discovery.DiscoveryProtocol] - Device scan: wait complete ...
19:23:06.227 [WARN ] [.internal.discovery.DiscoveryProtocol] - Ended Broadlink device scan...
19:23:06.238 [INFO ] [dlink.internal.socket.BroadlinkSocket] - Socket closed
19:23:06.248 [INFO ] [dlink.internal.socket.BroadlinkSocket] - Receiver thread ended
19:23:06.258 [INFO ] [l.discovery.BroadlinkDiscoveryService] - Discovery complete. Found 1 Broadlink devices
19:23:50.612 [DEBUG] [link.internal.BroadlinkHandlerFactory] - Creating Thing handler for 'broadlink:rm4'
19:23:50.622 [WARN ] [e.core.thing.binding.BaseThingHandler] - Handler BroadlinkRemoteModel4Handler tried updating its configuration although the handler was already disposed.
19:23:50.633 [DEBUG] [link.internal.BroadlinkHandlerFactory] - RM 4 handler requested created
19:23:50.650 [WARN ] [e.core.thing.binding.BaseThingHandler] - Handler BroadlinkRemoteModel4Handler tried updating its configuration although the handler was already disposed.
19:23:50.697 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: initializing
19:23:50.758 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: initialization complete. Updating status.
19:23:51.785 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: We've never actually successfully authenticated with this device in this session. Doing so now
19:23:51.796 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: Authenticating with packet count = 4954
19:23:51.831 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: java.net.ProtocolException: Response from device is not valid. (0x22=0xFF,0x23=0xFF,0x24=0xFF)
19:23:51.841 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: Attempting to authenticate prior to getting device status FAILED. Will mark as offline
19:23:51.851 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: updateItemStatus: Online -> Offline
19:24:21.870 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: We've never actually successfully authenticated with this device in this session. Doing so now
19:24:21.892 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: Authenticating with packet count = 4955
19:24:21.932 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: java.net.ProtocolException: Response from device is not valid. (0x22=0xFF,0x23=0xFF,0x24=0xFF)
19:24:21.950 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: Attempting to authenticate prior to getting device status FAILED. Will mark as offline
19:24:21.967 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: updateItemStatus: Online -> Offline
19:24:51.991 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: We've never actually successfully authenticated with this device in this session. Doing so now
19:24:52.007 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: Authenticating with packet count = 4956
19:24:52.063 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: java.net.ProtocolException: Response from device is not valid. (0x22=0xFF,0x23=0xFF,0x24=0xFF)
19:24:52.078 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: Attempting to authenticate prior to getting device status FAILED. Will mark as offline
19:24:52.108 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: updateItemStatus: Online -> Offline
19:25:22.124 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: We've never actually successfully authenticated with this device in this session. Doing so now
19:25:22.142 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: Authenticating with packet count = 4957
19:25:22.183 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: java.net.ProtocolException: Response from device is not valid. (0x22=0xFF,0x23=0xFF,0x24=0xFF)
19:25:22.197 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: Attempting to authenticate prior to getting device status FAILED. Will mark as offline
19:25:22.213 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: updateItemStatus: Online -> Offline
19:25:52.230 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: We've never actually successfully authenticated with this device in this session. Doing so now
19:25:52.248 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: Authenticating with packet count = 4958
19:25:52.291 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: java.net.ProtocolException: Response from device is not valid. (0x22=0xFF,0x23=0xFF,0x24=0xFF)
19:25:52.308 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: Attempting to authenticate prior to getting device status FAILED. Will mark as offline
19:25:52.326 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: updateItemStatus: Online -> Offline
…and so on and so forth!
Edit:
I removed the thing, re-scanned for it and re-added it. I now get a slightly different re-occuring error:
19:47:27.238 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: We've never actually successfully authenticated with this device in this session. Doing so now
19:47:27.255 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: Authenticating with packet count = 50962
19:47:27.272 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: java.lang.IllegalArgumentException: Empty key
19:47:27.288 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: Attempting to authenticate prior to getting device status FAILED. Will mark as offline
19:47:27.316 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[v]: updateItemStatus: Online -> Offline
empty key is quite strange, because I’ve certainly added the details into the thing configuration:
Thanks @X-Ray181
Are the Authentication Key and IV codes similar for all Broadlink RM models?
I would have thought every model has a unique set of codes, like every computer has a unique MAC address.
Hmmm - I’m wondering if the “BestCon” RM4 variation is a little more than skin-deep?
To see that "Response from device is not valid" message, the device must not be speaking the “Broadlink Protocol” - or at least maybe not using the same encryption key/vector as normal Broadlink-branded devices?
Can someone with a Broadlink-branded RM4 device confirm that they can successfully use it now?
In the meantime, here’s another BETA version (BETA 6) - this one has slightly improved send/receive performance so that if a device replies to the binding very fast, we have a better chance of hearing it. Also small improvements to logging:
I just add the latest version and have a new error message:
2020-04-30 10:15:07.414 [ERROR] [handler.BroadlinkRemoteModel2Handler] - rm2:0f32b178[^]: Failed to get MAP transformation service for thing Broadlink RM2; is bundle installed?
Is it refer to the broadlink.map file?
I have this file at: \openHAB-conf\transform folder, is it the right place?
Hi Yehuda,
You’ve probably got the map file in the correct place, but make sure you’ve installed the Map transformation add-on (it’s a separate element to the Broadlink binding and needs to be explicitly installed);
in PaperUI: Add-ons -> Transformations -> Map Transformation
Hi Michailis,
Yes - if you’re correct, someone will have to reverse-engineer the key/vector for BestCon devices, in the same way they did for the Broadlink devices.
I have no idea how that was done, and I certainly would not be able to do it. The only useful references I’ve ever found for the Broadlink protocol are this Ipsum Domus blog post and the Python Broadlink github repo.
Both mention the key and vector as if they are well-known quantities; but they most certainly are not - they are “secrets” that are internal to Broadlink (and the reason why the openHAB Broadlink binding does not have them hard-coded…)
My understanding is that to obtain them via reverse-engineering would require a combination of brute-force, mathematical talent and/or knowledge of the internal operation of the devices. Assuming that the BestCon devices are internally identical but use a different key/vector, it’s still a very difficult problem to solve. Perhaps someone with a BestCon device might like to approach the Ipsum Domus and/or Python guys and see if they can shed any light on how they got those magic values?
Hello, sorry, it may have been asked before, but can’t find the answer …
What is the IR code format in the map file … is it a standard format ? Like pronto HEX
The code starting by 2600 below
I’ve setup the python-broadlink scripts, and I’ve managed to toggle my IR light using the RM4C Mini that I have.
So it looks like it can be connected to, and we can use it to control IR devices.
I tried using the binding again (BETA_05), but I get the same result as in post #1116. Is it anything to do with the second screenshot in that post, where the id and key show as empty, despite definitely having entered the key and vector?
The key and iv are correctly stored in configuration. But properties has empty id and key parameters. What should the id and key parameters in properties store?
Does everyone know the better way to learn RD command? I have some single hand control for garage door and it’s working but for some motor that use RF433,92 it’s not working. I have tried many option and no one is able to learn buttons for this blinds motor… From econtrol and IHC it’s able to sweap the frequency, but not leanirng the button itself…
Appreciate the effort on this. Unfortunately this snapshot doesn’t seem to fix whatever the issue is. The empty id and key parameters still exist (if that is indeed the issue), and the thing still complains of a communication_error.
10:54:53.901 [INFO ] [l.discovery.BroadlinkDiscoveryService] - BroadlinkDiscoveryService - Constructed
10:55:23.616 [WARN ] [l.discovery.BroadlinkDiscoveryService] - BroadlinkDiscoveryService - Beginning Broadlink device scan...
10:55:23.647 [WARN ] [.internal.discovery.DiscoveryProtocol] - Beginning async Broadlink device scan; will wait 10000 ms for responses
10:55:23.698 [WARN ] [.internal.discovery.DiscoveryProtocol] - Broadlink device scan waiting for 10000 ms to complete ...
10:55:23.911 [INFO ] [l.discovery.BroadlinkDiscoveryService] - Data received during Broadlink device discovery: from 192.168.1.117:80 [24:df:a7:4f:7c:e6]
10:55:23.917 [DEBUG] [l.discovery.BroadlinkDiscoveryService] - Adding new Broadlink device on 192.168.1.117 with mac '24:df:a7:4f:7c:e6' to Smarthome inbox
10:55:23.923 [DEBUG] [l.discovery.BroadlinkDiscoveryService] - Device 'broadlink:rm4:24-df-a7-4f-7c-e6' discovered at '192.168.1.117'.
10:55:23.934 [INFO ] [ig.discovery.internal.PersistentInbox] - Added new thing 'broadlink:rm4:24-df-a7-4f-7c-e6' to inbox.
10:55:30.593 [DEBUG] [link.internal.BroadlinkHandlerFactory] - Creating Thing handler for 'broadlink:rm4'
10:55:30.600 [DEBUG] [link.internal.BroadlinkHandlerFactory] - RM 4 handler requested created
10:55:33.708 [WARN ] [.internal.discovery.DiscoveryProtocol] - Device scan: wait complete ...
10:55:33.713 [WARN ] [.internal.discovery.DiscoveryProtocol] - Ended Broadlink device scan...
10:55:33.719 [INFO ] [dlink.internal.socket.BroadlinkSocket] - Socket closed
10:55:33.725 [INFO ] [l.discovery.BroadlinkDiscoveryService] - Discovery complete. Found 1 Broadlink devices
10:55:33.725 [INFO ] [dlink.internal.socket.BroadlinkSocket] - Receiver thread ended
10:55:47.265 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: initializing
10:55:47.319 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: initialization complete. Updating status.
10:55:48.340 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: We've never actually successfully authenticated with this device in this session. Doing so now
10:55:48.348 [DEBUG] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: Authenticating with packet count = 30707
10:55:48.359 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: Authentication failed: Empty key
10:55:48.367 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: Attempting to authenticate prior to getting device status FAILED. Will mark as offline
10:55:48.373 [ERROR] [.handler.BroadlinkRemoteModel4Handler] - rm4:24-df-a7-4f-7c-e6[?]: updateItemStatus: Online -> Offline
I’ll certainly continue to help test snapshots. For now I’ve got something working with python_broadlink and broadlink_mqtt as per: