ESPHome IR Blaster: Passing NEC Data to Transmitter

Hey everyone,

I wanted to share my recent experience with setting up an ESPHome-based IR blaster. It’s been a fascinating journey, and I thought I’d document my findings in case anyone else is tackling a similar project.

So, here’s the setup: I purchased this ESP8266-based IR blaster from https://www.irblaster.info/wifi_ir.html. The goal was to integrate it into my ESPHome setup so I could control my devices via remote. While the initial setup went smoothly, I ran into a bit of a challenge when it came to passing the NEC data from the receiver to the transmitter.

Let me walk you through what I did:

  1. ESPHome Configuration: I started by loading ESPHome onto the device. The configuration was pretty straightforward, with the receiver set up on GPIO13 and the transmitter on GPIO5. I enabled logging to keep track of everything.

  2. Capturing NEC Data: The logs showed that the receiver was picking up NEC data whenever I pressed a button on my remote. For example, pressing the ‘On’ button resulted in logs like:

[19:24:30][D][remote.nec:070]: Received NEC: address=0x7C87, command=0xDA25

  1. The Challenge: The tricky part was figuring out how to capture this NEC data and pass it to the transmitter. I wanted to use the remote not just to control the IR blaster but also to trigger actions in my smart home setup.

  2. Solution: After some research and trial and error, I realized that I needed to create a custom sensor in ESPHome that captures the NEC data whenever it’s received. This sensor would then trigger the transmitter to send the same command. Here’s a snippet of the code I used:

esc_sensor:
platform: custom
name: “NEC Data”
icon: “mdi:remote”
lambda: |
return x.data.getstd::string(“nec_data”);

  1. Integration with Home Assistant: Once the sensor was set up, I configured it in Home Assistant to trigger the transmitter whenever the sensor state changed. This allowed me to use the remote to control both the IR blaster and other devices in my setup.

  2. Testing: Testing was a breeze. I used the remote to turn on my TV, and the logs confirmed that the command was captured and sent to the transmitter. It worked perfectly!

  3. Future Plans: Now that this is working, I’m looking into using the remote to control other devices in my home, like my lights and thermostats. The possibilities are endless!

I hope this helps anyone else who’s trying to achieve something similar. If you have any questions or suggestions, feel free to reach out. Happy coding!

Best regards,
[Your Name]