Data template for brightness

Hi,

I have a socket switch in my wall which i have swapped for a custom made blind plate switch like so:


The blind plate is touch sensitive and super easy to use. The sensor is connected to a Wemos D1 Mini with ESPHome. It runs great!
Right now i am only using it to turn on or off the light, but i’d like to be able to increase/decrease the brightness from that one switch.
I hope someone can help me create a data template to do the following:
If the touch sensor is pressed within a second: light toggles
If the touch sensor is pressed longer than 1 second: the light increases, if i let go and touch the sensor for another second, the light decreases.
I am able to create the automation for toggle, and for only increase or decrease brightness, but not for both.
I hope someone can help me!

Thank you in advance!

Your logic will never work with a single press for increase and decrease because the first press and hold will always take precedence over a supplemental one. Resulting in always increasing based on your logic. In theory, you could build a ‘time out’ after the increase has occurred to perform a decrease. Getting that to work with the current automation engine will be very difficult. Also, it would be a pain in the ass for a user to use. They’d spend more time standing at the physical switch than they would have without a smart switch/dimmer.

That’s exactly how the Clipsal one button dimmer works. Short press toggle; long press dim or brighten depending if it was the first second or second long press.

Basically it reverses the brightness direction at the end of each long press.

yes but that’s all handled by the button, not home assistant’s automation engine.

Yep. It’s not a smart button either. Works with an ir remote only. I was just pointing out that it would be possible after every long press detection to reverse the direction of brightness change. By toggling an input boolean perhaps.

1 Like

I know that the Shelly dimmer also works that way, that’s why I thought that it maybe was possible to do it like that.

Maybe I could make something in the esphome yaml? That platform also supports long presses (on_click). Someone experience or ideas with that?

Nevertheless thanks for the reply’s!