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. https://lprhodes.github.io/slate/
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 https://github.com/eschava/broadlink-mqtt
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'
If the MQTT IP address is 192.168.1.10, 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 192.168.1.10 -t broadlink/RM2_00_00_00/aircon/on -m auto
script:///usr/bin/mosquitto_pub -h 192.168.1.10 -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/mqtt.py
There is a homebridge plug in for homekit integration but I haven't tried or tested this. https://lprhodes.github.io/slate/
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 https://github.com/eschava/broadlink-mqtt
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 '192.168.1.101' (MAC 34:ea:34:01:01:01)
DEBUG Connected to RM2 Broadlink device at '192.168.1.102' (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 192.168.1.10 -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 192.168.1.10, 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 192.168.1.10 -t broadlink/RM2_00_00_00/aircon/on -m auto
script:///usr/bin/mosquitto_pub -h 192.168.1.10 -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/mqtt.py
Comments
python2.7 mqtt.py
Traceback (most recent call last):
File "mqtt.py", line 533, in
devices = get_device(cf)
File "mqtt.py", line 338, in get_device
return configure_device(devices[0], topic_prefix)
File "mqtt.py", line 384, in configure_device
device.auth()
File "/usr/local/lib/python2.7/dist-packages/broadlink/__init__.py", line 203, in auth
response = self.send_packet(0x65, payload)
File "/usr/local/lib/python2.7/dist-packages/broadlink/__init__.py", line 259, in send_packet
payload = self.encrypt(payload)
File "/usr/local/lib/python2.7/dist-packages/broadlink/__init__.py", line 169, in encrypt
encryptor = self.aes.encryptor()
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/primitives/ciphers/base.py", line 121, in encryptor
self.algorithm, self.mode
File "/usr/local/lib/python2.7/dist-packages/cryptography/hazmat/backends/openssl/backend.py", 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/ciphers.py", line 62, in __init__
mode.initialization_vector
TypeError: from_buffer() cannot return the address of the raw string within a str or unicode or bytearray object