Friday, August 24, 2018

Multiple Broadlink RM mini 3 integration using MQTT

Broadlink now has quite a lot of integration options almost out of the box. If you enable Broadlink IHC, you can directly link it to Alexa by giving the device a unique name.

There is a homebridge plug in for homekit integration but I haven't tried or tested this.

I wanted to put the device in domoticz so I can have more control over what can trigger my broadlink. I decided to use broadlink-mqtt for this, which is a fairly easy method to trigger from any source.

Setup Instructions for broadlink-mqtt

1. git clone

2. vi /home/pi/broadlink-mqtt/mqtt.conf

3. Update the mqtt.conf file with the device type set as multiple_lookup

device_type = 'multiple_lookup'
mqtt_multiple_subprefix_format = '{type}_{mac_nic}/'

4. Start the python script and check that it started and detected all the RM devices.

Check the log file to see what the IP / MAC addresses are.
DEBUG Connected to RM2 Broadlink device at '' (MAC 34:ea:34:01:01:01)
DEBUG Connected to RM2 Broadlink device at '' (MAC 34:ea:34:00:00:00)

5. Record the IR command - substitute the 00_00_00 with the last 3 octets of the mac address for the device. (I haven't tried this yet, as I previously added my commands when I only had 1 RM mini)

mosquitto_pub -h -t broadlink/RM2_00_00_00/aircon/off -m auto

6. Configure Domoticz virtual device to replay the IR command

If the MQTT IP address is, the following "On Action" can be used to turn on and off the broadlink virtual switch device created in Domoticz

script:///usr/bin/mosquitto_pub -h -t broadlink/RM2_00_00_00/aircon/on -m auto
script:///usr/bin/mosquitto_pub -h -t broadlink/RM2_00_00_00/aircon/off -m auto

Update to avoid python 2.7 errors, use python3.

$ sudo pip3 install paho-mqtt

and start by

$ python3 /home/pi/broadlink-mqtt/


wurst said...

hey, nice tutorial, but it doesnt work for me. i am getting
Traceback (most recent call last):
File "", line 533, in
devices = get_device(cf)
File "", line 338, in get_device
return configure_device(devices[0], topic_prefix)
File "", line 384, in configure_device
File "/usr/local/lib/python2.7/dist-packages/broadlink/", line 203, in auth
response = self.send_packet(0x65, payload)
File "/usr/local/lib/python2.7/dist-packages/broadlink/", line 259, in send_packet
payload = self.encrypt(payload)
File "/usr/local/lib/python2.7/dist-packages/broadlink/", line 169, in encrypt
encryptor = self.aes.encryptor()
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/ciphers/", line 121, in encryptor
self.algorithm, self.mode
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/", line 303, in create_symmetric_encryption_ctx
return _CipherContext(self, cipher, mode, _CipherContext._ENCRYPT)
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/", line 62, in __init__
TypeError: from_buffer() cannot return the address of the raw string within a str or unicode or bytearray object

Melven said...

use python3 instead. I updated the post at the end.

dead pi

Well, I guess it has to happen at some point. the home automation raspberry pi has died. Much to do with the stupid Strontium mini SD card. ...