One button ESP2866-01 / ESPHomeAPI light switch and dimmer?

I have been thinking that it might be possible to use an ESP2866-01 and ESPHomeAPI as a simple 1-button light switch and dimmer for HASS.IO so wondered if anyone has already done this?

The way these 1-button devices generally work is:

  • short press = toggle light on/off
  • long press = dim or bright (opposite of whatever the last long press did)

Is something like this possible or already been done?

Thanks.

https://esphome.io/components/binary_sensor/index.html#on-multi-click shows how to do long clicks.

Thanks, @nickrout - that will definitely help.

Can’t believe I missed that - I looked at the binary sensor but clearly didn’t look hard enough!

Richard