Sunday, 4 June 2017

HOME AUTOMATION: Using the Black Bean RM Mini 3 with openHAB

While there are a number of options out there for controlling infrared appliances like your TV and Air conditioner from your smartphone, none have come in at the price point of the Broadlink Black Bean RM Mini 3. I purchased 3 of the units from gearbest on flash sale for 12.89USD each with plans to use them only with the Broadlink app.

The app got old pretty quick so I started to dig in to openHAB integration. While there isn't an official openHAB binding for the devices there are a few python libraries out there for controlling the black bean. Combine those python scripts with the Exec binding and we can roll our own openHAB solution.


Python Library Setup

Go ahead and configure the RM Mini devices per the Broadlink instructions, then set a static IP on your router for each of the devices. We need to do this because the python control script reference the device by IP address. 

Install the python-broadlink library and test the basic functions to ensure the library is working. 
 cd ~/addons/  
 git clone  
 cd python-broadlink  
 python build  
 python install  

Test the installation by running python in the command line and testing a few of the functions in the readme:
 >>> import broadlink  
 >>> print  
 [<broadlink.rm instance at 0x7661XXXX>, <broadlink.rm instance at 0x7661XXXX>, <broadlink.rm instance at 0x7661XXXX>]  
 >>> quit()  

The above confirms that the library found 3 devices on my network.

Now that we have confirmed the python-broadlink library is working, install the blackbeancontrol library:
 cd ~/addons/  
 git clone  
 cd BlackBeanControl  

Test the library is working as expected by first configuring a default unit in the BlackBeanControl.ini and then attempting to learn a command. If the command argument name exists then it will be executed by the device, otherwise it will put the device in to the leaning state and wait to lean the command and save it for future use:
 python -c LG_TV_Vol_Down

If everything went to plan you should have seen the device go in to learning mode, learn the command, then if running the same command again you should have seen the command executed.
Next step is to pair this python script with the exec binding to enable control from openHAB.

openHAB Setup

Depending on how you would like to control your RM Mini from openHAB there are a few ways to configure your items and sitemap. I've previously written up a few examples on this topic.

Typically I want my IR devices to function like a push button remote so I use items and rules to create my buttons (as opposed to things and items with the exec binding).

String TV_GF_Power "TV Power"

 rule "LG TV Power"  
     Item TV_GF_Power received update  
     executeCommandLine("python /home/openhabian/addons/BlackBeanControl/ -c LG_TV_Power -d Lounge", 1000)  

Switch item=TV_GF_Power mappings=[OFF="Power"]  


  1. Thank you! You made my day. I had some issues running these because i used python3. With python 2 everything went smooth.

  2. Hello mate!!
    How to write rule for a keypad??I have a keypad in my UI, but not sure how to send the command to each one of them.