Hello, I have a problem with configuring my AC dimmer in ESPHome. I migrated from Arduino IDE to ESPHome recently because I want to integrate the dimmer into Home Assistant.
My hardware:
- ESP32 DevKit V1
- rbdimmer 1CH 8A module
- Gate pin connected to GPIO18
- Zero-cross pin connected to GPIO19
- Load: 150W halogen lamp, 230V
In Arduino IDE I was using the rbdimmerESP32 library and everything worked fine. Now I want to do the same thing in ESPHome but I am not sure which component to use. I searched the ESPHome documentation and found several output platforms (ledc, sigma_delta, slow_pwm) but none of them seem correct for an AC TRIAC dimmer.
Is there a specific ESPHome component for AC phase-cut dimming? Or do I need a custom component? It makes no sense for me to use PWM because that is for DC loads, not AC.
I tried the following but it still doesn’t work:
output:
- platform: ledc
pin: GPIO18
id: dimmer_output
This just makes the lamp flicker badly — which makes sense because LEDC is a PWM output, not phase-cut.
What is the correct approach for AC dimming in ESPHome?
The component you need is ac_dimmer — it’s a dedicated ESPHome platform for TRIAC phase-cut dimming.
Here’s my working YAML:
output:
- platform: ac_dimmer
id: dimmer_output
gate_pin: GPIO18
zero_cross_pin:
number: GPIO19
mode: INPUT
method: leading pulse
Key points:
gate_pin — this is the TRIAC trigger pin (your dimmer output pin)
zero_cross_pin — the ZC signal from the module. Must be set to INPUT mode explicitly
method: leading pulse — this is the standard method for TRIAC dimmers. There’s also leading but leading pulse is more reliable in my experience
I’ve been running this on my setup (ESP32, HA 2024.12, ESPHome 2024.11) for about 3 months with no issues. The ac_dimmer platform handles all the zero-cross detection and TRIAC timing internally — no custom component needed.
Replace your ledc output with the ac_dimmer block above and the flickering should stop immediately.
Hank’s YAML is correct for the basic setup. I’d add two important parameters that improve the dimming experience significantly:
light:
- platform: monochromatic
name: 'Living Room Dimmer'
output: dimmer_output
gamma_correct: 1.0
And in the output section, you might want to fine-tune:
output:
- platform: ac_dimmer
id: dimmer_output
gate_pin: GPIO18
zero_cross_pin:
number: GPIO19
mode: INPUT
method: leading pulse
min_power: 25%
min_power: 25% — this sets the minimum brightness level where the lamp stays stable. Below this value most lamps (especially LEDs and halogens) will flicker or turn off. Setting it to 25% means when you slide the brightness to minimum in HA, it stops at 25% instead of going lower into the unstable range.
gamma_correct: 1.0 — by default ESPHome applies gamma correction (2.8) which makes the dimming curve feel non-linear. For AC dimmers the library already handles the power curve, so setting gamma to 1.0 gives you a linear 0-100% mapping that matches what you expect.
I measured the output with my oscilloscope at various brightness levels and the phase angle tracks linearly with the power setting when gamma is 1.0.
Thank you all — this is very helpful. But I have one more question: how do I set this up as a proper light entity in Home Assistant with a brightness slider?
Right now if I only define the output: section, it appears in HA as a switch (on/off) but without brightness control. I think I need the light: section that Ola and rbdimmer mentioned, but I want to make sure I have the complete configuration correct.
Could someone show me the full YAML — both output and light sections together?
UPDATE: I got it working! Here is my final complete YAML for anyone who finds this thread later:
esphome:
name: living-room-dimmer
esp32:
board: esp32dev
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
api:
encryption:
key: !secret api_key
logger:
output:
- platform: ac_dimmer
id: dimmer_output
gate_pin: GPIO18
zero_cross_pin:
number: GPIO19
mode: INPUT
method: leading pulse
min_power: 25%
light:
- platform: monochromatic
name: 'Living Room Dimmer'
output: dimmer_output
gamma_correct: 1.0
zero_means_zero: true
This gives me a proper light entity in Home Assistant with a brightness slider. The dimmer turns truly off at 0% and dims smoothly from 25% to 100%. The halogen lamp is stable across the entire range.
Thank you Hank for the ac_dimmer component, Ola for the min_power and gamma_correct tips, and rbdimmer team for the zero_means_zero parameter. Everything works perfectly now.