A ceiling light controlled by an infrared remote can be connected to Home Assistant with a small ESP32 that can both receive and transmit the remote’s codes. The remote is then no longer needed.
The components and pins below are a typical choice; specific modules may differ.
Components
- ESP32-C3 (e.g. an ESP32-C3 SuperMini development board);
- a 38 kHz IR receiver (VS1838B or TSOP38238);
- an IR LED with an NPN transistor (e.g. 2N2222) and resistors, or a ready-made transmitter module.
Wiring
On the ESP32-C3 it pays to avoid GPIO2, GPIO8 and GPIO9 – they determine the boot mode.
1. Capturing the codes
First you need to find out the protocol and the button codes of the remote. One way is a simple sketch in the Arduino framework with the IRremoteESP8266 library (the IRrecvDumpV2 example), which prints the protocol and code to the serial line when a button is pressed. The other way is to go straight to ESPHome with dump: all – the codes show up in the log.
2. ESPHome configuration
remote_receiver:
pin:
number: GPIO4
inverted: true
mode:
input: true
pullup: true
dump: all
remote_transmitter:
pin: GPIO5
carrier_duty_percent: 50%
button:
- platform: template
name: 'Ceiling light'
on_press:
- remote_transmitter.transmit_nec:
address: 0x00FF # example - values from your own capture
command: 0x40BFEach remote button worth controlling gets its own button. The protocol (transmit_nec, transmit_raw and others) matches what the capture showed.
3. Home Assistant
After the firmware is flashed, the device appears in Home Assistant through the ESPHome integration, and the buttons are available as entities – for manual control and for automations.
Things to watch out for
- IR needs a direct line of sight to the light’s receiver; place the transmitter so it can “see” it.
- The device does not know the light’s state – IR is one-way. If an automation needs it, it has to be derived another way (e.g. with a light sensor).