Broadlink RM mini 3

Controlling appliances through IR repeater Broadlink RM mini 3

Some control panels examples of devices driven by the IR remote control.

Amplifier control Classic UI or App

Amplifier control Basic UI

Amplifier control Habpanel

Air conditioner control Classic UI or App

Air conditioner control Basic UI

Air conditioner control Habpanel

Controlling appliances through IR repeater Broadlink RM mini 3

Using Broadlink RM mini 3 InfraRed remote control repeater to control various appliances.

This device, and its bigger companion that can also emulate 433MHz RF remote controls, are very common and widespread in the home automation environment. On the Net there are many usage examples with all the most popular automation systems.

On this page a deep inside view of the device.

First of all, it must be linked to the WiFi network using the dedicated app as well explained on user manual and on the tutorials available abroad. The registration to the cloud services is not needed if you don’t want to backup the device internal configuration.

The procedure described below requires a fixed IP address to register the device in the library together with its MAC address.

A Python library has been written using the API available for the RM mini 3. There are a lot of tutorials to configure it in OpenHAB. This is one of the best, even if it’s not completely correct. Below some further operations needed to have a full working configuration.

Starting from the basic, official OpenHAB 2.2 installation, with pip installed, it also need to install Python openSSL, otherwise it’s not possible to install Python add-ons:

sudo apt-get install openssl python-openssl

Installing the configparser, netaddr e pycrypto modules has explained in the tutorial the program works only if launched as openhabian user console, not through the OpenHab 2.2 exec binding. They must be installed in the default folder to be available for all the users:

sudo pip install --target=/usr/local/lib/python2.7/dist-packages configparser
sudo pip install --target=/usr/local/lib/python2.7/dist-packages netaddr
sudo pip install --target=/usr/local/lib/python2.7/dist-packages pycrypto

After installation and configuration of the various remote control keys as described in the tutorial, they can be tested from the console before proceeding with OpenHAB configuration.

The tutorial refers to the OH 1.1 exec binding, the new OpenHAB 2.2 binding works according to the new specifications. The commands must be added as things as in this example:

things/rm3.things

Thing exec:command:AmpliON [command="/usr/bin/python /home/openhabian/addons/BlackBeanControl/BlackBeanControl.py -c AmpliON", interval=0, timeout=5, autorun=false]
Thing exec:command:AmpliOFF [command="/usr/bin/python /home/openhabian/addons/BlackBeanControl/BlackBeanControl.py -c AmpliOFF", interval=0, timeout=5, autorun=false]

They have to be linked to items to be used:

items/rm3.items

Switch AmpliON_RUN "Ampli ON" <"player"> {channel="exec:command:AmpliON:run"}
Switch AmpliOFF_RUN "Ampli OFF" <"player"> {channel="exec:command:AmpliOFF:run"}

and used in standard mode through UI or HAB panel, for example:

sitemaps/cm3home.sitemap

Frame label="Remote Control"
        {
            Text item=AmpliON 
            {
                Switch item=AmpliON_RUN
                Switch item=AmpliOFF_RUN
            }
        }
Air conditioner control example

The air conditioner protocols are a jungle, each brand designs its own. The only thing in common is the way they transmit the data. At every key stroke all the parameter set is resent, this is because the pressure of the remote control buttons is completely asynchronous with respect to the actual reception, the receiver could also be out of range. From a point of view it’s simpler to send the data in this way, the packet is prepared with all the information needed and it is sent in the same way at every stroke. From another point of view the work of preparing the packets with applications like the Python program for the Broadlink RM 3 mini we are talking about is very tedious, it needs to prepare a series of packets for all the possible combination of operating mode, temperature and fan speed. Even limiting the possible range the number is quite high.

A real LG heat pump air conditioner case will be used as an example.

To reverse engineer the commands sent by the remote control, The AnalysIR software has been used with the USB Infrared Toy hardware from Dangerous Prototypes. As evident on the software web site many other hardware can be used, from the ubiquitous Arduino, to the ESP8266 or Raspberry PI.
AnalysIR immediately recognizes the protocol as LG28AC. This is a 28-bit protocol with a 4-bit checksum, for a total of 32 bits sent at each stroke. A good starting point to analyze the packet meaning has been found in the Arduino forum. The checksum algorythm is discussed on Stackexchange forum.

Once the database with all the needed commands has been prepared, it must be linked to the OpenHAB system. With the basic UI or classic UI we can use the Selection element type.

items/AC.items

Number AC_mode "Mode"  (AC)
Number AC_fan "Fan"  (AC)
Number AC_temp "Temp"  (AC)
Switch AC_on    "ON" (AC)
Switch AC_send "OK"  (AC)
String AC_string "[%s]"  (AC)
Number AC_changeFlag (AC)

sitemaps/cm3home.sitemap

Frame label="Air Conditioner"
		{
			Text label="Air Conditioner" icon=snow
			{
				Selection item=AC_mode label="Mode [%s]" mappings=[0="Cold", 1="Dehumidify", 3="Auto", 4="Warm"]
				Selection item=AC_fan label="Fan [%S]" mappings=[0="Low", 2="Medium", 4="High", 5="Chaos"]
				Setpoint item=AC_temp label="Temp [%.1f °C]" minValue=20 maxValue=25 step=1 
				Switch item=AC_send
				Switch item=AC_on
				Text item=AC_string
			}
		}

In the habpanel, it gets complicated a little bit because there are no ready-made multi-selection modes but they must be configured with the infinite possibilities made available by the supported programming languages.

On the OpenHAB forum there are many discussions about this issue

In this example has been used the Marcel Verpaalen’s  widget modified by Anders Alfredsson.

These items are linked to a series of rules to have a behavior as similar as possible to the original remote control.

For the aforementioned reasons the temperature range has been limited between 20 and 25°C, with more patience it can be extended. The default at power on is 23°C with lower speed fan. In the dehumidifier mode the temperature is automatically set by the system, in other operating modes the temperature and fan speed can be changed once the system is powered on.

rules/AC.rules

var ac_mode = 1
var ac_on = OFF
var ac_fan = 0
var ac_temp = 23
var ac_send = OFF
var Timer set_timer = null
var Cmd="/usr/bin/python@@/home/openhabian/addons/BlackBeanControl/BlackBeanControl.py@@-c@@"

rule "Start"
when
	System started
then
	AC_mode.postUpdate(ac_mode)
	AC_on.postUpdate(ac_on)
	AC_fan.postUpdate(ac_fan)
	AC_temp.postUpdate(ac_temp)
	AC_send.postUpdate(ac_send)
	AC_changeFlag.postUpdate(0)
end

rule "Send"
when 
	Item AC_send received command ON
then
	ac_mode=AC_mode.state 
	ac_fan=AC_fan.state 
	
	if (AC_mode.state == 1) //mode DRY
	{
		ac_temp=23
		AC_temp.postUpdate(ac_temp)
	}
	else
	{
		ac_temp=AC_temp.state 
	}

	if (AC_on.state==OFF)
	{
		ac_on=ON
		AC_on.state=ac_on
		AC_string.postUpdate("AC-ON_"+ac_mode+"_"+ac_fan+"_"+ac_temp)
		AC_changeFlag.postUpdate(1)
	}
	else
	{
		AC_string.postUpdate("AC-"+ac_mode+"_"+ac_fan+"_"+ac_temp)
		AC_changeFlag.postUpdate(1)
	}

			set_timer = createTimer(now.plusSeconds(1))
            [
				AC_send.postUpdate(OFF)
				set_timer = null
            ]   
end 

rule "AC_ON"
when 
	Item AC_on received command ON 
then
	ac_on=ON  
	ac_mode=AC_mode.state 
	ac_fan=AC_fan.state 
	ac_temp=AC_temp.state 
	AC_string.postUpdate("AC-"+ac_on+"_"+ac_mode+"_"+ac_fan+"_"+ac_temp)
	AC_changeFlag.postUpdate(1)
end 

rule "AC_OFF"
when 
	Item AC_on received command OFF
then
	AC_string.postUpdate("AC-OFF")
	AC_changeFlag.postUpdate(1)
	ac_on=OFF 
	ac_temp=23
	ac_fan=0
	AC_fan.postUpdate(ac_fan)
	AC_temp.postUpdate(ac_temp)
end

rule "Check_ON"
when 
	Item AC_fan changed or Item AC_temp changed
then
	if (ac_on==OFF)
	{
		ac_temp=23
		ac_fan=0
		AC_fan.postUpdate(ac_fan)
		AC_temp.postUpdate(ac_temp)
	}
end 

rule "Send Command"
when 
	Item AC_changeFlag changed to 1
then
	val results = executeCommandLine(Cmd+AC_string.state,5000)
    	logInfo("Exec",results)
	AC_changeFlag.postUpdate(0)
end 

In this mode the AC_string string is composed and used as a parameter for the Python program through the executeCommandLine instruction.

Of course each string must match with a string in /addons/BlackBeanControl/BlackBeanControl.ini prepared with the parameters that have to be used with Broadlink RM 3 mini.

For example

IPAddress = 192.168.1.79
Port = 80
MACAddress = 34:ea:34:8f:83:b3
Timeout = 10

[Commands]
AC-OFF = 260040000001258b113410130f130f130f360f130f1310130f35103510130f130f1310130f130f130f140f130f130f1310130e3610130f350f1410120f130f3610000d050000000000000000
AC-ON_0_0_23 = 260040000001268a10350f1310130f130f360f130f130f140f130f130f140f130f130f1311120f130f360f130f130f1410120f130f140f130f3510130f130f1310000d050000000000000000
Links

Share