Broadlink binding for RMx, A1, SPx and MP. Any interest?

well these debug lines are what will help @themillhousegroup fix it :slight_smile:

Yep I see the problem. Expect a new binding in a few hours :crossed_fingers:

1 Like

Hi John,

Any idea on what is the problem here? I really has no clue on what to do. The RM2 is working well to control any IR devices but not communicate with openhab.
I try to reinstall the jar and also go to some old versions, reset both openhab and RM2, nothing help.
Appreciate you help and support.

2020-04-29 08:30:36.803 [vent.ItemStateChangedEvent] - Remote changed from 1.0 to 2.0
2020-04-29 08:30:36.806 [vent.ItemStateChangedEvent] - ZWaveNode016_SceneNumber changed from 1.0 to 2.0
2020-04-29 08:30:36.828 [ome.event.ItemCommandEvent] - Item ‘Broadlink’ received command TV_POWER_OFF
2020-04-29 08:30:36.869 [nt.ItemStatePredictedEvent] - Broadlink predicted to become TV_POWER_OFF
2020-04-29 08:30:36.897 [vent.ItemStateChangedEvent] - Broadlink changed from TV_POWER_ON to TV_POWER_OFF
2020-04-29 08:30:36.915 [ERROR] [handler.BroadlinkRemoteModel2Handler] - rm2:0f32b178[^]: Broadlink RM2

Thanks

Yehuda

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 (:roll_eyes:)

Needless to say, I forgot to do the bottom task :slight_smile:

Please find a new binding which should be much better for RM4 owners here:
https://github.com/themillhousegroup/openhab2-addons/releases/download/BROADLINK_2.5.BETA_05/org.openhab.binding.broadlink-2.5.1-SNAPSHOT.jar

Cheers,
John

2 Likes

I just install this new version, still see the same problem

Like @Yehuda, I can confirm “Error - 409 Conflict” is still showing when using Beta 5.

[EDIT] I waited a few seconds and tried again. This time, the RM4 Pro was added successfully. Thank you!!!

Now I need to learn how to obtain the Authentication Key and IV…

Search “smartnydom broadlink” may help with key

1 Like

The IV & Vector Key:
Key = 097628343fe99e23765c1513accf8b02
Vector =562e17996d093d28ddb3ba695a2e6f58

1 Like

This is great, thanks John!

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:

However, strangely, when clicking the blue tick on the page above, then clicking show properties for the thing, the id and key say <empty>:

Clicking on the blue pencil/edit icon on the page above returns me back to the configuration for the thing, and the key and IV are still filled in…

Thanks @X-Ray181 :pray: :pray:
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:

https://github.com/themillhousegroup/openhab2-addons/releases/download/BROADLINK_2.5.BETA_06/org.openhab.binding.broadlink-2.5.1-SNAPSHOT.jar

Hi John,

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?

Thanks,
Yehuda.

hi,
i have bestcon RM4c and i have the same problem as hafniumzinc described,
i also believe that the device doesnt speak the broadlink protocol,

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

Cheers,
John

1 Like

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

SAMSUNG_NETFLIX = 260046008D9511390E3C0F3A10160E1510160D180F150F3A103C0E3B0E1D0A160E15101412140F3F0B3A10160F151039103B0F3A0D3C10150F180D3B103A10140F180D1611160A000D050000

Thank you

My map file looks like that, and it works

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 missing key and vector is extremely odd - can I suggest you try re-entering them to see if they “stick” the second time around?

I wonder whether the empty id and key properties are a red herring. Checking the jsondb file for things:

/var/lib/openhab2/jsondb/org.eclipse.smarthome.core.thing.Thing.json contents:

       "configuration": {
        "properties": {
          "deviceType": 25278,
          "mapFilename": "broadlink.map",
          "retries": 1,
          "authorizationKey": "097628343fe99e23765c1513accf8b02",
          "port": 80,
          "staticIp": true,
          "ipAddress": "192.168.1.117",
          "pollingInterval": 30,
          "ignoreFailedUpdates": false,
          "iv": "562e17996d093d28ddb3ba695a2e6f58",
          "mac": "24:df:a7:4f:7c:e6"
        }
      },
      "properties": {
        "id": "\u003cempty\u003e",
        "key": "\u003cempty\u003e"
      },

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?