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

Today I got my RF blinds working with OH2+Broadlink RM Pro.

It is possible to control Broadlink Pro using this Python library https://github.com/mjg59/python-broadlink and the exec binding (http://docs.openhab.org/addons/bindings/exec/readme.html).

Next step is to use the IR to control AC and TV. As it is the same process, I think it´ll be easy to accomplish.

If someone has interest I can detail the steps and try to help.

2 Likes

@Botura as you got the RMPro working I’m very interested! I plan on using its RF capabilities to send commands to various devices. Obviously I have it working using the Broadlink app. Any help in the initial RMPro/OpenHab set up is most welcome.

@Botura finally managed to get your library installed. My openhabian version didn’t seem to recognise setuptools which I fixed by installing pip.

Setup went well and I used 3 python scripts from the domoticz board for RM to scan, learn codes, and play back codes. Both IR and RF. So far only in the shell. Openhab next.

So what’s left is

  1. figure out how to set up the Exec binding
  2. capture the codes from the Broadlink TC2.
  3. see if I can get homekit to recognise the Exec bindings. Although iOS home app sees a Samsung TV I set up and Siri recognises the name, Home will switch it off but Siri won’t. Got to figure that out.

Thanks a ton for your code. Note a native binding but very cool and can be used elsewhere due to Python.

Hi @r4m235, this library is not mine, I just found it and realize that it can be used with OH…

Great that you have everything working in the shell.

Here is an example of how to setup OH. I had to use rules because I´m using rollershutter.

// things
Thing exec:command:openBlind1 [command="python /etc/openhab2/broadlink/cli/broadlink_cli --device @/etc/openhab2/broadlink/cli/mb/broadlink1.device --send @/etc/openhab2/broadlink/cli/mb/blind1.open", interval=0]
Thing exec:command:closeBlind1 [command="python /etc/openhab2/broadlink/cli/broadlink_cli --device @/etc/openhab2/broadlink/cli/mb/broadlink1.device --send @/etc/openhab2/broadlink/cli/mb/blind1.close", interval=0]
Thing exec:command:stopBlind1 [command="python /etc/openhab2/broadlink/cli/broadlink_cli --device @/etc/openhab2/broadlink/cli/mb/broadlink1.device --send @/etc/openhab2/broadlink/cli/mb/blind1.stop", interval=0]


// items
Switch openBlind1 { channel="exec:command:openBlind1:run"}
Switch closeBlind1 { channel="exec:command:closeBlind1:run"}
Switch stopBlind1 { channel="exec:command:stopBlind1:run"}
Rollershutter Blind1 "Blind 1"

// Sitemap
Switch item=Blind1


//rules
rule "Send commands to blind 1" 
when 
Item Blind1 received command
then
if (receivedCommand == UP)
	openBlind1.sendCommand(ON)
else if (receivedCommand == DOWN)
	closeBlind1.sendCommand(ON)
else
	stopBlind1.sendCommand(ON)
end
2 Likes

To capture codes I´m using the broadlink_cli file that is included in the github link.

sudo python /etc/openhab2/broadlink/cli/broadlink_cli --device @broadlink1.device --learnfile ./samsung.ch_up

Where broadlink1.device is a text file containing type, IP and MAC of broadlink:

0x2712 192.168.0.4 34EA34F43AC0p
1 Like

@Botura I’m using the scan, learn, and send scripts from here: http://www.domoticz.com/forum/viewtopic.php?f=17&t=6929&hilit=broadlink&start=100#p103517

I’ve added the Things and Items as per your info and they appear in PaperUI in Things, but each with a name of “Command”. If I try to edit the name (or location) I get an error “ERROR: 409 - conflict” and the update doesn’t stick. Do you have the same issue? Same error if I try to change the repeat interval. I wanted to change the interval because otherwise the command seems to repeat eg. a command is send to switch LED lights on, another command is sent to switch LED lights off, and these repeat every 60 seconds (default setting). I’m interested if you also had this and solved it.

edit: the conflict was because you can’t use text files and the UI for configuring the same items - live and learn :slight_smile: SO I configured the names, locations, intervals in the text file and it works.

Hello!

You can try my script to control Broadlink devices. It started as RM3 Mini script, but it could be used with RM Pro, and some other Broadlink devices too. It incorporates learning and sending codes in one script, and it uses python-broadlink library:

https://github.com/davorf/BlackBeanControl

There is a topic about controlling broadlink devices located here:

https://community.openhab.org/t/broadlink-black-bean-rm-3-mini-ir-controller-integration-in-openhab/11453?u=davorf

Best regards,
Davor

2 Likes

HI,
I am new to OpenHab and have gone through the steps here
http://blinkingled.cc/broadlink-black-bean-rm-3-mini-ir-controller-with-openhab/

to set up the Broadlink device.
I can execute the python script to turn on and off the device this is all working fine. I have installed Exec Binding.
However, I can’t get the python script to be executed by OpenHab. Not sure what I am doing wrong

Items file has this line
Switch HeaterSwitch "Heater" <fire> {exec=">[ON:python /usr/share/openhab2/exec/BlackBeanControl/BlackBeanControl.py -c HeaterON] >[OFF:python /usr/share/openhab2/exec/BlackBeanControl/BlackBeanControl.py -c HeaterOFF]"}

My sitemaps file has this
Switch item=HeaterSwitch

I can execute the
python /usr/share/openhab2/exec/BlackBeanControl/BlackBeanControl.py -c HeaterON

From any directory on the PI so it is not a path or permissions issue.

Installed the Exec binding through PaperUI.

Not sure if I am missing a step here

thanks

Thanks very much!
Works great!

Assuming you are using oh2, I think you must use things with the exec binding. It was not necessary with oh1.

With the oh2 I would recommend to just remove the new exec binding and install the legacy one. It is rather complicated to have the new binding execute different things on switch on and off state.

1 Like

Hi
not sure how to do that.
I added the Exec binding though Paper UI.
Are you saying to disable that. and setup a manual binding.

How do I do that?

sorry still a OPenHab Noob

In Paper UI you have to enable legacy bindings under Configuration - System - Add-on Management. After that you can find the old exec binding in the addon manager. Install that after you have removed the new exec binding.

Thanks. Fixed it…

Hi,
Apologies for the delay. I had to focus on other more critical and important things for awhile.
I’ll be posting the beta broadlink addon later tonight after I have written down some instructions on how to get it working.

Cato

4 Likes

Hi all,
Under you can find the links to download a Broadlink binding together with instructions on how to get it working on your system. Supported devices in this version are:

• RM and RM2 - IR and RF transmitter with temperature sensor and Wi-Fi connectivity
• RM3 - IR transmitter with Wi-Fi connectivity
• A1 - multi sensor that can detect temperature, humidity, illumination, background noise and air quality

In addition, it includes code to support three kinds of smart sockets (listed under). Since I don’t have any of these they are untested and may not work.

Drop me a message if you have any of these devices and are interested in working with me to get them working with the binding.

• SP1 - smart socket with Wi-Fi connectivity
• SP2 - as above with addition features
• MP1 - four port power strip with Wi-Fi connectivity

Also, with this being the first version I do expect there will be issues. Please post whatever problems you are having and I will do my best to sort them out.
The binding can be downloaded here: (see later post for latest version) Once downloaded, place it in your openhab/addons folder.

Step by Step

Step 1: Inside openhab go to your Inbox and search for devices using the Broadlink binding. If the binding does not find your devices make sure that they are on the same network and are online.

Step 2: For each found device click on the “Add” button to add it as a thing.

Step 3: Go to your Thing screen under Configuration and click on the device you added above.

Step 4: For each device you are required to enter a common Authentication Key and IV parameter. These were obtained and shared by someone who reversed engineered the protocol and such due to legal reason I cannot post these two items here. If you do not have these two then Google is your friend. Both need to be entered in hex string format by omitting the 0x. For example, if the key is something like 0x09, 0x76, 0x28… you will enter this as 097628… Once done, you should have two hex strings, each with a length of 32 characters.

Step 5: For RMx devices only. The Map file refers to the file that holds the IR/RF codes. It defaults to broadlink.map but you can change it to something else if you prefer. Go to your openhab/transform folder and create a broadlink.map file using your favourite text editor.

Step 6: For RMx devices only. In this step, we will find IR/RF code to insert into the broadlink.map file. Go to http://rm-bridge.fun2code.de/rm_manage/code_learning.html to learn the various IR/RF codes. After learning a function you should see something like this:

{“api_id”:1004,“command”:“send_code”,“mac”:“B4:43:0D:38:FA:9D”,“data”:“260068000001289314101312143513121411131213111411133613361510143614351336143614351411133615101411131213111313131014361412123712361436133615351435140005230001274815000c4d0001284a12000c4d0001284915000c4b00012a4814000d05”}
Insert the data string into the broadlink.map file together with the function. For example, I inserted the following line into broadlink.map for turning on my tv.

TV_POWER_ON = 260068000001289314101312143513121411131213111411133613361510143614351336143614351411133615101411131213111313131014361412123712361436133615351435140005230001274815000c4d0001284a12000c4d0001284915000c4b00012a4814000d05

Insert a new line for each of the function you want openhab to control.

Step 7: For RMx devices only. Create an item in your items file and add it to your sitemap.

item file:
String TV_LIVINGROOM “TV” { channel=“broadlink:rm2:b4-43-0d-38-fa-9d:command” }

sitemap file:
Switch item=TV_LIVINGROOM label=“Power” mappings=[TV_POWER_ON=“On”, TV_POWER_OFF=“Off”]

Next Steps:
• Resolve reported bugs
• Get this thing on GitHub
• Implement support for Broadlink Alarm Kit

Drop me a message if you are having any problems with the binding.

Cato

32 Likes

Will try soon.

Very good Binding !!

1 Like

Hi,

I forgot to mentioned in my post that the possible values for illumination, background noise and air quality are as follows:

Illumination
DARK
DIM
NORMAL
BRIGHT

Background noise
QUIET
NORMAL
NOISY
EXTREME

Air quality
PERFECT
GOOD
NORMAL
BAD

Cato

1 Like

this is always the same?
googles leads me to some wiresharked stuff only that looks wrong

I use the same keys for RM3 PRO and A1.
You have to provide them once for each thing You would like to add.