Broadlink Black Bean (RM 3 Mini) IR Controller - Integration in OpenHAB

(Will Waterston) #82

Thanks for those pointers, I’ll attempt to set that up in the next couple of days.

One other question I had was what is the best way to implement a toggle switch? In this case there is only 1 button for the power on most AV appliances and it just sends the same command for ON/OFF. Secondly, since there is no state feedback from the the blackbean (or my AV applicances) as to the power state ON or OFF, then Openhab really is never sure if the device is on or off so having a status indicator in the switch display does not have any practical use.

Extending this we have commands to set, for example, the video source on the AV receiver. I hope that Openhab has some sort of virtual switch that can have multiple (enumerated?) states that would simply show the state as the last command sent. I’ll check the OH doco for something like this.

(davorf) #83


The only way I’m aware of, regarding toggle switch, is using autoupdate=“false” in binding config part of the item - {binding=“xxx”, autoupdate=“false”}. Besides that, you should use mapping in the sitemap, so the switch would be represented as button (mappings[ON=“Power”]). Regarding your second question, I’m using Network binding TCP connection to port 8080 to examine if the TV is ON. For the virtual switch you could use either Selection, or switch with multiple mappings, and then parse it and use executeCommandLine inside rule.

Best regards,

(Lionello Marrelli) #84

Let me add that I was able to operate a broadlink eAIR sensor with a slightly modified version of Davorf script. If someone is interested I may give some more details.
I noticed that the script may occasionally hang if there’s some network glitch, blocking the exec binding (no other calls, even the ones not connected to the stuck script, are executed anymore) until openhab is restarted.
With the mini the probability of this behavior is much lower but not zero.
As a workaround I used the TIMEOUT command in linux preceding the script.

Best Regards

(Jumpkick) #85

Had some trouble getting running on Ubuntu 16.04 last week…

Ended up having to explicitly prefix easy_install with python2 (i.e. ‘sudo python2 $(which easy_install) pycrypto configparser netaddr’) to get easy_install to install the 2.x packages instead of the 3.x package… Then had to patch it to auto-detect my RM3 because I couldn’t get it to find it using the IP/Mac address I put in .ini… It probably starts a bit slower but I got it working, I’ll have to do another couple of pulls on a different machine to see if it works better now.

I was originally going to post here asking if there was a way to manually discrete IR codes from RemoteCentral into the .ini… Then I figured it wouldn’t be because it looks like even a learned code ends up a different encrypted payload in the .ini each time it’s captured… (It would be cool if we could store these as unencrypted codes somehow)

Then I thought of another way; went into my junk bins and pulled out my ancient Logitech Revue… After battling it for about 20 minutes, I was able to get it to spew discrete IR codes for my TV’s power on, power off, HDMI1 and HDMI2… This made me very happy as I can now consistently order the TV and know it’s end state, which I could not do by learning from the remote alone (which has only Toggle Power and Next Input).

Those looking for reliable automation would do well to borrow someone’s Logitech Harmony Remote (take the base unit too if the IR blaster isn’t in the remote) and set-up the device’s discrete codes and then capture them.

(davorf) #86


There was some pretty fundamental change in broadlink package, so, my script wasn’t compatible to use it with for a few days. I’ve made a patch a user on github suggested, so, you should try using the latest version of the script - pushed to the github repository on 23rd November.
Regarding the second part of your post, I’m not sure I understand what you’re trying to accomplish. I do decrypt a package, then unhexlify it, before saving it to the BlackBeanControl.ini. Problem is, if you reset your RM3, it will use different package for the same command. Pure IR code is not very useful, because it’s incorporated into whole package, and then encrypted, so, you can’t make a useful package out of it.

Best regards,

(davorf) #87


@Lionello_Marrelli @dontpanic @Farhanito and others: do you think it would be easier to use RM3 control via RESTful API? I could make a script/service using Python and Flask, so commands could be reached via REST/HTTP binding from OpenHAB. What do you think, is it worth the effort?

Best regards,

(eschava) #88

My broadlink is still on the way but I already started new project with MQTT interface to broadlink python library
I think MQTT protocol is more convenient for openHab integration than REST/HTTP

(Lionello Marrelli) #89

I do not know the REST/HTTP binding therefore I cannot appreciate its advantage over the EXEC binding ( is it more robust towards script hanging or failing for some reason? Can it return back data that can be handled more easily in openhab?). A possible advantage is that the RESTful API could be accessed from openhab instances running on nodes where python cannot be installed (a setup similar to the http bridge android app).


(davorf) #90

Hello Lionello!

That was exactly what I was thinking - making Python application similar to Android RM Bridge. You can trigger commands/learning just by calling web URI, so, it could be used from other devices in the local network too. Setup would remain the same (.ini with General settings - default parameter for device, Commands and custom devices).

I’m not very familiar with MQTT (don’t have a single device using it), so, I can’t comment on that.

Edit: It could return data, but, since there is no feedback from IR devices, I don’t see any reason for including feedback (except error messages and error handling).

Best regards,

(Will Waterston) #91

I’ve done only a small amount of work with REST and I’m not very familiar with it so its hard to comment. However, using the Python script and the broadlink package via exec binding is working well for me, and I seem to prefer it this way. Any device or protocol that does not have a direct binding I use exec binding and an appropriate script, that works for me. Even if I need to have some bash scripts, some Perl scripts, some Python scripts I keep them in one place and the Openhab configurations are simpler.

I also use MQTT to communicate with some devices since its a fairly simple and reliable interface.

But also thanks for the offer to do this:)

(farhan) #92


I think one of the advantage of RESTful API is that you can create easier web interface for codes/config management. Especially if the config and codes are stored in JSON format. (like RM Tasker plugin)

(Jumpkick) #93

@davorf - The updated code worked much better, with the config it dispatches IR commands very quickly (way faster than my auto-detect hackiness), so good stuff there. Still not clear if the same code is packaged differently between different physical Blackbeans or if it’s just encoded differently each time, haven’t looked captures in the latest build to see if that changed, just thinking it would be cool if we could have consistant IR codes so we could trade them and reduce duplicates… That way learned discrete codes (not available to folks without harmony remotes to learn them from) could be shared by those who have access to them.

Here are some installation notes for Ubuntu:

sudo apt install git python-dev python-setuptools
git clone
cd python-broadlink/
sudo python2 install
cd ..
git clone
sudo python2 $(which easy_install) pycrypto configparser netaddr # must specify which python, otherwise it will only install for highest version
nano BlackBeanControl/BlackBeanControl.ini # Put in your mac, ip, port, etc
chmod +x BlackBeanControl/ # bad interpreter on Ubuntu, so must invoke using python2 explcitly
python2 BlackBeanControl/ --help # do something

(davorf) #94


I’m not sure I understand what you mean with “discrete codes (not available to folks without harmony remotes to learn them from)”. The same code is different every time you reset your RM3, so, it’s not just different physical devices that have different codes. I guess it’s encryption that changes it. Anyway, encryption of a sent code is done by the Broadlink Python package and, since I’m just using that package, I have no power over an encryption algorithm or the keys it’s using.

Best regards,

(Jumpkick) #95


Discrete IR codes are IR commands that are end states rather than toggles,
a lot of remotes only have toggles (i.e. a single button for power button
for both on & off that when pushed just toggles power to be NOT current
power value), for automation that sucks because if the TV/Stereo/whatever
is already on when an automation sequence starts, the automation will
toggle it to off and mess everything up. If you look in a tv manual, often
you can find discrete codes not on the remote like “PowerOn”, no matter how
many times this code is sent, the result will be the same (If the TV is off
PowerOn turns it on, if it’s on, nothing happens).

The manuals sometimes document these discrete IR code sequences, and
universal remote products like Logitech Harmony make use of them to
orchestrate complicated activities (I.e. “play a game” = turn tv on, set
input HDMI 2, turn Stereo on, set input to optical, turn PlayStation on)

Anyway, since the physical buttons for those codes don’t exist on the
remote, they must either be input manually (impossible because of
encryption it seems) or learned from a smart remote (like a Harmony) or
some IR blaster that has them… so it means no giving codes from those who
have access to those who don’t. Bummer that it doesn’t even stay the same
across resets.

(davorf) #96


@jumpkick After a bit of research I’ve found out ZappIR android application can send those discrete codes too. It has separate codes for Power On, Power Off, HDMI 1, HDMI 2 etc. Since many newer Android smartphones have IR blaster, it could help people without Harmony/Smart remotes learning and reproducing those discrete codes via BlackBeanControl and RM3.

Best regards,

(Joakim) #97

I just managed to capture IR codes with this:

I am able to test the code via this webpage and it works well!

This is the data I got for my TV power on:
And this is for a light (ir operated):

But they look much shorter than the examples posted here.
What is missing from the codes?

As I said they work well when using them on the page I posted a link to.
I have tried Packet Sender with this posted to HEX and I get no reaction at all?

(davorf) #98


I think that Broadlink Android API (used by RM-Bridge) adds some parts of the payload in the moment of sending, so, I don’t think it’s possible to send python captured payloads via RM-Bridge web interface, or vice versa.

Best regards,

(Joakim) #99

After I posted this I actually tried installing tcpdump to my Android phone and using Terminal to run it like this: tcpdump -vv -s 0 -w /sdcard/filename.pcap

I then opened the broadlink app on the same phone and learned codes. After that I opened the pcap in Wireshark.
I found a payload that looked like the codes posted here in QUIC, beginning with 5a… but this didn’t work (tried sending it with Packet Sender and nothing happened).

Where did I do wrong?
And what package is my IR code, and how do I extract it?

(Joakim) #100

Now I actually managed to get two codes through Wireshark:

I tried them in Packet Sender, and they worked. But when trying again they don’t work. If I wait for a while and try again, they work. They are not discrete code, it is the same for on and off.
Why is there a wait time before working again?

(Joakim) #101

davorf, I’m sorry about the confused replies I sent before. I finally managed to find out the IR-codes with Wireshark. And I have now read up about the problem with sending the same IR-code multiple times. And that you had a solution for this with dummy codes.

I use a Homebridge plugin called homebridge-rm-mini3, which sends IR-codes to the Broadlink RM3 Mini. This works very well now, but I am not able to send the same code multiple times. The developer doesn’t seem to have a solution for the dummy code.
I have tried to get help from him without any success.

Can you point me in the right direction. I should be able to add a line of code to this:

Which sends a dummy code?