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

You might need to “tidy up” your .map file, checking for spaces, newlines etc in the IR codes. The binding requires an IR code to be a multiple of 16 bytes in length (I have no idea why, it was like that in the original binding; I assume it’s a requirement of the RM- devices themselves).

As another working example for you to try, here’s the first two entries in my broadlink.map:

PANASONIC_AIRCON_ON = 2600bc017438100d0f2a0f0d100d0f0d100d0f0e0f0d0f0e0f0d0f0e0f0d0f0e0f2a0f0d100d0f0d100d0f0e0f0d0f0e0f2a0f2a0f2a100d0f0d1029100d0f0e0f0d0f0e0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0e0f0d0f2a1029100d0f0e0f0d0f0e0f0d100001487338100d0f2a100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f2a100d0f0d100d0f0d100d0f0d100d0f2a10291029100d0f0e0f2a0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0e0f2a0f0d100d0f2a0f0e0f0d0f0e0f0d100d0f0d102a0f0d0f0e0f2a0f0d100d0f0d100d0f0d100d0f0d100d0f0d102a0f2a0f2a0f2a1029100d0f2a100d0f2a0f2a0f0e0f2a0f2a0f0e0f0d0f0e0f0d0f0e0f0d0f0e0f0d100d0f0d0f0e0f0d100d0f2a0f2a1029100d0f0d100d0f0d100d0f0d100d0f0e0f0d10291029102a0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f2a100d0f0d100d0f0d100d0f0d1029100d0f0e0f0d0f0e0f0d0f0e0f0d100d0f0d100d0f0d1408100d100d0f0d100d0f0d1029102a0f2a0f2a100d0f2a0f2a10000d05000000000000000000000000

PANASONIC_AIRCON_OFF = 2600bc017338100d1029100d0f0d100d0f0d100d0f0d100d0f0e0f0d0f0d100d0f2a100d0f0d100d0f0d100d0f0d100d0f2a1029102a0f0d0f0e0f2a0f0d100d0f0d100d0f0d100d0f0e0f0d0f0e0f0d0f0e0f0d0f0e0f0d0f0e0f0d0f0e0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d102a0f2a0f0d100d0f0d100d0f0e0f00014874380f0e0f2a0f0d100d0f0d0f0e0f0d100d0f0d100d0f0d100d0f0d102a0f0d100d0f0d100d0f0d100d0f0d102a0f2a0f2a0f0e0f0d0f2a100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0d100d0f0e0f0d0f0e0f2a0f0d0f0e0f0d100d0f0d100d0f2a0f0e0f0d0f2a100d0f0e0f0d0f0e0f0d0f0e0f0d0f0e0f0d0f2a0f2a102a0f2a0f2a0f0e0f2a0f0d1029102a0f0d0f2a102a0f0d0f0e0f0d0f0e0f0d0f0e0f0d0f0e0f0d100d0f0d0f0e0f0d102a0f2a0f2a0f0e0f0d0f0e0f0d0f0e0f0d0f0e0f0d0f0e0f2a0f2a0f2a0f0e0f0d0f0e0f0d100d0f0d100d0f0d100d0f0d100d0f0e0f0d0f0e0f0d0f0e0f2a0f0d100d0f0d100d0f0d100d0f2a0f0e0f0d0f0e0f0d0f0e0f0d0e0f0f0d0f0e0f0d100d0f0d0f0e0f0d100d0f0e0f2a0f0d0f2b0f2a0f2a0f0e0f2a0f2a0f000d05000000000000000000000000

I feel like you should be able to “pad out” the IR code to a multiple of 16 with zeroes (a zeroed byte will be 00) without doing much harm … ?

Thank you very much for your explanation.
It means that codes stored by the version of BroadlinkControl.py I use are stored in a different format than the one accepted by the binding.
I’ll try with a newer version. Hopefully this will solve the issue that the ir code of the same remote is coded completely differently by each rm mini.
Thanks,
Lionello

EDIT: I verified that the python code BroadlinkControl.py stores data encrypted. Once decrypted it can be copied into the map file that can be used by the binding.

Hey guys,
Does anyone have tried to control the binding through amazon alexa?
If do so, could someone provide item and rule example?
Thank you in advance.

Hi @themillhousegroup, first of all I want to thank you for this great contribution. I abandoned binding version 2.2 long time ago due to many reconnection and general reliability issues time ago. It have been working more or less fine through executecommand calling python script, but I now realise it was slow and some times had to send the IR code twice to get it to work. Now with 2.4 b10 new binding everything goes very quick and reliable

The only strange thing is that the logs are filled with communication error messages:

2018-12-30 06:29:44.039 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: updateItemStatus: Online → Offline
2018-12-30 06:33:23.287 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: Problem getting status. Marking as offline …
2018-12-30 06:33:23.290 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: updateItemStatus: Online → Offline
2018-12-30 06:41:03.923 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: Problem getting status. Marking as offline …
2018-12-30 06:41:03.926 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: updateItemStatus: Online → Offline
2018-12-30 06:43:10.006 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: Problem getting status. Marking as offline …
2018-12-30 06:43:10.010 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: updateItemStatus: Online → Offline
2018-12-30 06:46:46.579 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: Problem getting status. Marking as offline …
2018-12-30 06:46:46.581 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: updateItemStatus: Online → Offline
2018-12-30 06:54:22.877 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: updateItemStatus: Online → Offline
2018-12-30 06:59:32.437 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: updateItemStatus: Online → Offline
2018-12-30 07:04:15.035 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: Problem getting status. Marking as offline …
2018-12-30 07:04:15.038 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:rm2:78-0f-77-17-f1-35[^]: updateItemStatus: Online → Offline
2018-12-30 07:06:33.846 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:sp2:34-ea-34-f5-b1-06[^]: null response from model 2 status request
2018-12-30 07:06:33.852 [ERROR] [.handler.AbstractLoggingThingHandler] - broadlink:sp2:34-ea-34-f5-b1-06[^]: Problem getting status. Marking as offline …

But the truth is that even when it says marking as offline, the IR commands works perfectly and quick. As far as I can tell It haven’t failed a single time in the last week, but logs are plenty of this messages

Happy new year everyone!
I have a question, I have a Sony Projector which is using the same command for Powering ON and OFF, the only difference with the OFF command is that needs to be repeated once to finally switch OFF the projector.
Any .rules suggestion would be appreciated.
Thank you in advance,
Mike

That’s really strange @Dixon - I suspect turning logging up to TRACE level (see further up this thread to see how to do that in the OpenHAB console) might explain that a bit better.

You might also experience an improvement from downloading and using BETA-11 which I’ve just published.

This version attempts to improve general reliability. The Broadlink network protocol always acknowledges every command sent to a device, so logically, the sendPacket() and receivePacket() functions have been coalesced to sendAndReceivePacket(). This in turn allowed for a simple retry mechanism to be implemented. If we time out waiting for a response from the device, we immediately retry, sending the packet again. Together with some improved logging, this should hopefully be enough to fix (or at least understand) devices prematurely being marked “offline” on unreliable networks.

https://dl.bintray.com/themillhousegroup/generic/org.openhab.binding.broadlink-2.4.0-BETA-11.jar

The reason that page doesn’t work with an RM3 is that the page’s JavaScript in learn.js tests for the device code, and ignores the “RM3” code which your device has. So you can add

type == "RM3" ||

to the end of line 80 of learn.js and it will recognise those devices.

2 Likes

The JavaScript in learn.js used by that page filters out RM3 type devices as far as I can see - so see my note just above about modifying line 80 of learn.js to enable RM3 device type.

Answering my own question, to use alexa on/off commands with broadlink rm products.
This post from @themillhousegroup worked great for me Broadlink binding for RMx, A1, SPx and MP. Any interest?

Thanks a lot

Unfortunately even after BETA-11 I still get the messages that after a few hours my SP3’s are not found anymore on the network.
I tried with and without static IP’s, but no luck so far… Also reset the SP3’s completely and reinstalled again; no luck.
Any ideas?

==> /var/log/openhab2/openhab.log <==
2019-01-05 19:35:04.732 [WARN ] [internal.discovery.DiscoveryProtocol] - Device scan: wait complete ...
2019-01-05 19:35:04.739 [WARN ] [internal.discovery.DiscoveryProtocol] - Ended Broadlink device scan...
2019-01-05 19:35:04.745 [INFO ] [link.internal.socket.BroadlinkSocket] - Socket closed
2019-01-05 19:35:04.750 [INFO ] [link.internal.socket.BroadlinkSocket] - Receiver thread ended
2019-01-05 19:35:32.727 [WARN ] [nal.discovery.DeviceRediscoveryAgent] - DeviceRediscoveryAgent - Beginning Broadlink device scan for missing BroadlinkDeviceConfiguration [ipAddress=192.168.178.31 (static: false), port=80, mac=EE:08:6B:F5:B0:71, pollingInterval=30, mapFilename=null, authorizationKey=097628343fe99e23765c1513accf8b02, iv=562e17996d093d28ddb3ba695a2e6f58]
2019-01-05 19:35:32.731 [WARN ] [internal.discovery.DiscoveryProtocol] - Beginning async Broadlink device scan; will wait 5000ms for responses
2019-01-05 19:35:32.747 [WARN ] [internal.discovery.DiscoveryProtocol] - Broadlink device scan waiting for 5000 ms to complete ...
2019-01-05 19:35:37.751 [WARN ] [internal.discovery.DiscoveryProtocol] - Device scan: wait complete ...
2019-01-05 19:35:37.753 [WARN ] [internal.discovery.DiscoveryProtocol] - Ended Broadlink device scan...
2019-01-05 19:35:37.760 [INFO ] [link.internal.socket.BroadlinkSocket] - Socket closed
2019-01-05 19:35:37.768 [INFO ] [link.internal.socket.BroadlinkSocket] - Receiver thread ended
2019-01-05 19:35:40.761 [ERROR] [handler.BroadlinkSocketModel3Handler] - sp3:89be66a1[^]: Exception while getting status from device
java.net.ProtocolException: Incoming packet from device is null.
	at org.openhab.binding.broadlink.internal.BroadlinkProtocol.decodePacket(BroadlinkProtocol.java:193) ~[256:org.openhab.binding.broadlink:2.4.0.201901041112]
	at org.openhab.binding.broadlink.handler.BroadlinkSocketModel2Handler.getStatusFromDevice(BroadlinkSocketModel2Handler.java:47) [256:org.openhab.binding.broadlink:2.4.0.201901041112]
	at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.updateItemStatus(BroadlinkBaseThingHandler.java:204) [256:org.openhab.binding.broadlink:2.4.0.201901041112]
	at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler$1.run(BroadlinkBaseThingHandler.java:79) [256:org.openhab.binding.broadlink:2.4.0.201901041112]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
2019-01-05 19:35:40.767 [ERROR] [handler.BroadlinkSocketModel3Handler] - sp3:89be66a1[^]: Problem getting status. Marking as offline ...
2019-01-05 19:35:40.769 [ERROR] [handler.BroadlinkSocketModel3Handler] - sp3:89be66a1[^]: updateItemStatus: Online -> Offline

==> /var/log/openhab2/events.log <==
2019-01-05 19:35:40.791 [me.event.ThingUpdatedEvent] - Thing 'broadlink:sp3:89be66a1' has been updated.
2019-01-05 19:35:40.853 [me.event.ThingUpdatedEvent] - Thing 'broadlink:sp3:89be66a1' has been updated.
2019-01-05 19:35:40.857 [hingStatusInfoChangedEvent] - 'broadlink:sp3:89be66a1' changed from ONLINE to OFFLINE (COMMUNICATION_ERROR): Could not find device at IP address 192.168.178.13

Thank you Michael, how do i add that line if the learn.js is on the server side?

Firefox and Chrome both allow you to edit source files including JavaScript in Developer mode. Open js/learn.js in the Sources tabs of the Developer window, and edit it. Hit Ctrl-S to have the page use the edited version - but don’t reload the page (when you do, your changes will disappear I think).

Alternatively, may I introduce a better way - a tool I just created which doesn’t have prejudices against RM3 or any other model, and which produces an output which can be easily copy-pasted into the broadlink.map file. Simply download the whole repository to a local folder and open index.html in your browser:

1 Like

Thanks Michael I shall give it a go :slight_smile:

Hi John,

I tried beta 11, it has the same flawless performance as beta 10, but now I get the same stack trace errors that @Jorg reported

2019-01-09 11:16:48.208 [ERROR] [handler.BroadlinkSocketModel2Handler] - sp2:34-ea-34-f5-b1-16[^]: Exception while getting status from device
java.net.ProtocolException: Incoming packet from device is null.
	at org.openhab.binding.broadlink.internal.BroadlinkProtocol.decodePacket(BroadlinkProtocol.java:193) ~[235:org.openhab.binding.broadlink:2.4.0.201901041112]
	at org.openhab.binding.broadlink.handler.BroadlinkSocketModel2Handler.getStatusFromDevice(BroadlinkSocketModel2Handler.java:47) [235:org.openhab.binding.broadlink:2.4.0.201901041112]
	at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler.updateItemStatus(BroadlinkBaseThingHandler.java:204) [235:org.openhab.binding.broadlink:2.4.0.201901041112]
	at org.openhab.binding.broadlink.handler.BroadlinkBaseThingHandler$1.run(BroadlinkBaseThingHandler.java:79) [235:org.openhab.binding.broadlink:2.4.0.201901041112]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
	at java.lang.Thread.run(Thread.java:748) [?:?]
    2019-01-09 11:16:48.218 [ERROR] [handler.BroadlinkSocketModel2Handler] - sp2:34-ea-34-f5-b1-16[^]: Problem getting status. Marking as offline ...
    2019-01-09 11:16:48.223 [ERROR] [handler.BroadlinkSocketModel2Handler] - sp2:34-ea-34-f5-b1-16[^]: updateItemStatus: Online -> Offline

I had similar issues with a A1 device. The problem was bad wifi reception quality.

@themillhousegroup Hello John, I have a Broadlink A1 and I’m wondering why the temperature polling is so inconsistent.

I have set the parameter in PaperUI -> Configuration -> Things - to 30 seconds but it clearly doesn’t work.

As you can see in my events.log there is no data sometimes for about 20 minutes.

2019-01-13 18:06:38.582 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.399999618530273 to 21.5
2019-01-13 18:07:09.042 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.5 to 21.399999618530273
2019-01-13 18:27:14.428 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.399999618530273 to 21.299999237060547
2019-01-13 18:28:45.196 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.299999237060547 to 21.399999618530273
2019-01-13 18:29:15.282 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.399999618530273 to 21.299999237060547
2019-01-13 18:46:19.565 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.299999237060547 to 21.200000762939453
2019-01-13 18:46:49.624 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.200000762939453 to 21.299999237060547
2019-01-13 18:49:20.348 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.299999237060547 to 21.200000762939453
2019-01-13 18:50:20.836 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.200000762939453 to 21.299999237060547
2019-01-13 18:52:21.470 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.299999237060547 to 21.200000762939453
2019-01-13 19:26:01.091 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.200000762939453 to 21.100000381469727
2019-01-13 19:27:31.668 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.100000381469727 to 21.200000762939453
2019-01-13 19:35:03.290 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.200000762939453 to 21.299999237060547
2019-01-13 19:45:08.681 [vent.ItemStateChangedEvent] - BroadlinkA1192168112_Temperature changed from 21.299999237060547 to 21.399999618530273

Hi @bccrew;
Looks like you have some rule firing on the output of your A1 Item, and you’ve used (correctly) the Item ItemName changed trigger to only do something if the temperature is actually different to the previous value. As the A1 is only capable of indicating temperatures with a 0.1C resolution, it’s quite possible for nothing to have changed for 20 minutes or more in a normal room!

If you’re concerned that something is not working properly, I can suggest two options to see more detail:

  • Alter the .rule that is producing the log output, changing the when Item ItemName changed trigger to when Item ItemName received update - this will make the body of the then run every time the A1 is polled;
  • Increase the logging level for the Broadlink binding (see further up this thread) - if you change it to the maximum level of detail (TRACE) - you’ll see something like this every 30 seconds (or whatever your polling frequency is):
2019-01-14 11:40:58.674 [TRACE] [broadlink.handler.BroadlinkA1Handler] - a1:403c9a3e[^]: updateItemStatus; checking host availability at 10.240.0.201
2019-01-14 11:40:59.081 [TRACE] [broadlink.handler.BroadlinkA1Handler] - a1:403c9a3e[^]: A1 getStatusFromDevice
2019-01-14 11:40:59.086 [TRACE] [broadlink.handler.BroadlinkA1Handler] - a1:403c9a3e[^]: building message with count: 23517, id: 02000000, key: 7DD2B603EAB8A362579F9041C4857D20
2019-01-14 11:40:59.093 [TRACE] [broadlink.handler.BroadlinkA1Handler] - a1:403c9a3e[^]: Sending A1 device status to 10.240.0.201:80
2019-01-14 11:40:59.099 [TRACE] [broadlink.handler.BroadlinkA1Handler] - a1:403c9a3e[^]: Sending A1 device status complete
2019-01-14 11:40:59.104 [TRACE] [broadlink.handler.BroadlinkA1Handler] - a1:403c9a3e[^]: Receiving A1 device status
2019-01-14 11:40:59.128 [TRACE] [broadlink.handler.BroadlinkA1Handler] - a1:403c9a3e[^]: Received A1 device status
2019-01-14 11:40:59.175 [TRACE] [broadlink.handler.BroadlinkA1Handler] - a1:403c9a3e[^]: A1 getStatusFromDevice got temperature 23.8

Notice that last line :slight_smile:

1 Like

Cato,
This sounds exactly like what I am looking for. Please send me a link to binding. Thank you!

I am a little confused about how to get this working. I followed the steps to get it setup (thanks, that was an excellent step by step walkthrough) but I’m having a hard time knowing how to use them.

Basically I want to use OH2 with HabPanel as a remote control. So I want to create a dashboard with buttons, and when I press the button I want it to execute the command.

I got a little lost on step 7. I’m not sure how to setup multiple buttons/commands. And I don’t know how to use the String to execute a command when the button is pressed. Could anyone please help me with this?

Hi John,

Actually I don’t have any rules that act on these kind of changes but I would like to push data from the sensor in an influx database and make a nice graph with grafana. The only problem is that I need that data every 30 seconds to push it into the database to be able to build a nice graph line.

I’m not really sure which strategy I should enter in my persistence file but like this it doesnt really work:

Strategies {
    everyMinute : "0 * * * * ?"
    everyHour   : "0 0 * * * ?"
    everyDay    : "0 0 0 * * ?"
}

Items {
    BroadlinkA1192168112_Humidity, BroadlinkA1192168112_Temperature  : strategy = everyMinute
}

Can you please check my logs attached here? This is my output with TRACE enabled. The temperature is polling every 30 seconds but the Humidity is not?

openhab.log (80.4 KB)
events.log (2.5 KB)