MQTT to control Broadlink RM Pro

Hi all,

I just started with tinkering with Home Assistant few weeks back.

I have previously setup AlexaPi on a Raspberry Pi and also bought one Broadlink RM Pro to control some of the IR enabled devices in my home.

Instead of controlling the IR enabled devices through the e-Control (broadlink app), I m hoping to be able to control the devices from AlexaPi. Since the Alexa Voice Service (AVS) is not capable of performing local discovery on the devices in the same local network, I will need to find an alternative to make my AlexaPi to talk the devices.

That is how i came across HA and using IFTTT to trigger components HA through rest API. But, this requires me to open up a local secure tunnel using Ngrok or perform some port forwarding on my router.

Due to some restriction, I have no access to my router and the port forwarding solution will not work in my case. Besides that, I have some concern having to expose the home assistant web api to the internet (Maybe can share some suggestion on how to make this more secured?)

Then, I also found out that there is another options to trigger events on Home Assistant from Alexa, which is to send message to a MQTT broker and have HA listening to a certain topic. I have subscribed to a free plan on CloudMQTT and setup a trial MQTT Light component to listen to message from CloudMQTT.

Using a MQTT client to publish message, I m able to send message to trigger On/Off for the MQTT light on the HA. But, the problem is that I want to use the same setup to trigger the IR device that i have already setup on HA using the Broadlink component.

I m not sure if there is any way to have a component listening to the MQTT message and forward it to the broadlink component? I m new to Python and still reading the HA documentation. Perhaps anyone can shed some light on this?

Thanks alot.

I think i can use the Automation to detect the state of virtual MQTT switch.

Then, when the state changes to on, the IR switch under Broadlink platform can be triggered.

I m still confused on how components and platform work. Have to read the documentation.

@themojoloo did you succeed ?

i am so curious to know to retrieve the current status of a switch.

your help will be appreciated

Can I ask what IR devices you are looking to control?

You may be interested in my setup, which is as follows:
I have a python RM Pro <-> mqtt client ( which allows full control of an RM Pro through a local mqtt broker. (I used to use the one built-in to HA, but have moved to an instance of Mosquito).

The python code allows for simple commands or macros involving pretty complex instructions to be sent to IR/433MHz devices though one mqtt publication. I have macros set up for various things - turning on a TV and set-top together (a surprisingly complex set of instructions), turning some tea lights on and putting them in flicker mode, turning to a specific TV channel, for example. I then have a corresponding HA mqtt switch for each function I want (e.g. Family Room TV).

I then use some simple node red code to translate between the HA mqtt publication and the python app (so if “homeassistant/set/family_room_tv ON” is published (following a switch change within HA) then node red publishes “broadlnk/tv_on macro” (and then the python code instructs the RM Pro to broadcast).

I expose the HA switches to Alexa by way of a Hue emulation. This allows me to say “Alexa, turn the TV on”. Or “Alexa, turn the lights off”, as I have exposed a HA group including (1) wall lights (2) 3 x sonoff plugs (3) some battery powered candle tea lights as one emulated Hue device. (I name the Hue device something obscure like eh_family_room_light_group and then have a group in the Alexa app called “lights” containing only that device). Or “Alexa, turn on channel 3”.

The final step is to have a bit more node red code which listens for e.g. “broadlnk/tv_on macro” and then publishes “homeassistant/state/family_room_tv ON”, which allows HA to accurately reflect the state of a device following an external charge by e.g. an Alexa command.

(I could probably do the node red translations in automations within HA, but I suspect this would be more more complex to code and harder to debug.)

All in all, this is a pretty robust and flexible setup, and I am pretty pleased with how it’s going. It is family friendly, and all the software (other than Alexa) runs happily on a Pi and no data leaves my house (other than Alexa). If I ever choose to replace HA then all the mqtt infrastructure will be able to stay in place.

(Now I write this down it seems complex - but it really isn’t that bad!)

1 Like

Hello @PlanSom your library sounds like the perfect solution, but I’m getting the following error message… any ideas? I’m using phyton 3.6 on Unbuntu 16.04
File “”, line 67
except Exception, e:
SyntaxError: invalid syntax

Hi @ccastillo

I recently changed the machine that I run that prog on, and the current version produced no problems for me.

I see that line 67 is in the middle of a if device.type == 'MP1': - is your device actually an MP1? What is your config?