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

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…