IR Light Switch + MQTT + ESP8266

Hello Experts

I was wondering if you could guide me on the following:

I have an IR Dimmer Light Switch connected to 230V mains that controls the LED dimmers and is controlled by an IR remote controller.

I was thinking of connecting an IR emitter to a ESP8266 which controls the light switch after retrieving the IR codes of the IR remote controller. The ESP8266 would then be controlled by HA via MQTT.

Do you guys think this is possible? If yes, could you please guide me on how to get the ESP8266 linked to HA via MQTT i.e. HA controlling the IR remote?

Many thanks for your comments and taking the time to read my post.

1 Like

You can use Broadlink RM2 pro, control the any IR device you want.

That seems a good idea but I have many IR light switches in different rooms and floors, would the Broadlink RM2 pro be able to control the light switches on different floors?

Different floors, you can use several RM Mini. Cheap enough :grin:

Control command from HA to RM Mini via the wifi network, every Broadlink device has different IP address.

That sounds great but I have already ordered the esp8266 board and the IR emitter which is why I thought I could link it to HA via MQTT.

Here is my configuration


I am not intending to use Broadlink unfortunately simply because I have ordered the ESP8266 board and the IR Emitters.

Use esp8266+MQTT+Emitter, decoding IR remote-code is a HARD working!

Trust me! I do have spended many many hard working. Finally, I gave up!

Use Broadlink, several minutes, mission accomplished. :grin:

I have decoded the IR Remote all I need now is to put the codes in the ESP8266 board and link it to HA via MQTT.

If I do fail however I will consider Broadlink.


how about this - just omit the RF

Thanks phileep.

I am looking into it now and wondering how to modify the IR file as it contains codes for various brands of TVs. I need to insert the codes for my IR Remote to control the IR light switch. Do you have any idea or have you done a similar project like this before?

Thanks again.


What do you mean by IR file?
Regarding the gateway that @phileep pointed you just need to add your wifi and mqtt broker parameters, no needs to modify the IR commands.
-Set the parameters of wifi and mqtt
-upload the sketch into your esp8266
-put the IR diode with a transistor if you have
-subscribe with your borker to the topic home/sensors/ir
-press your remote control in front of the diode during several seconds
-record the code
-publish with your broker the code to the topic “home/commands/sendNEC”
-if not working try different send topics

Next step is the HA connection on which there is several subjects dealing with it.

IR File : I meant the one that contains the IR codes in my case I am not using a TV instead I have the IR codes for my switch light remote which I thought I would have to put in the file/sketch?

no you don’t need to put the codes in the file/sketch. The gateway is only a bridge between your MQTT broker and the IR signal (in both directions)
You publish a remote code from your file (by a command) to your broker and the gateway will translate it into an IR signal.

If you have mosquitto an example will be:
mosquitto_pub -t home/commands/sendSony -m 3609272523
3609272523 is the code coming from your file (copy/paste)

Cliking enter and pointing the IR diode to the right direction close enough to the device you want to control should command it.

This first step is for testing your setup.

ok I have a few questions for you:
1). I could use any IR remote i.e. not a TV Remote?
2). Can I use your setup without an IR receiver? because I have already decoded my IR remote control and have the codes.

  1. you could use other thing than a tv remote, Hifi, light, robot vaccuum …
  2. yes you can but I don’t advise because it depends on which format you stored your code, I’m not confident on this

I just tested the gateway with a cheap chinese IR led strip remote control and it worked, here is what I get in receiption

home/sensors/ir 4294967295

ok perfect !

when I publish the code to my broker to the topic “home/commands/sendNEC” will these codes be stored permanently or would I have to send it everytime?

and finally if I do not want to use rf how shall I remove it from your setup? I only want to use IR.

You will have to send it everytime but this task will be done at final by HA, and you will store the code into the HA configuration.

Regarding RF let it like that it should work the same

no I mean I am NOT going to use RF will this still work? or do I have to remove RF from the sketch etc?

yes it will work