Multiple triggers and actions with a single switch

Hi,

I have a Philips Hue bridge which is of course connected to my HA set-up. On this Hub I have connected a Friends of Hue (FoH) switch which I want to use to control some smart (Hue) bulbs.

The idea is to use a single switch button to execute different actions. E.g. if I do a short press, it should toggle the light. If hold the switch for the first time, the brightness should be increased. On the second hold action the idea is to decrease the brightness.

In fact I have it already working, but not using Home Assistant. I accomplished this behavior using the Hue Essentials app. This approach has some downsides, as it is just using the Philips Hue Bridge. I prefer to have it in a code-programmed way. Also, from time to time the app crashes or the configuration gets messed up as I changed something and then I have to recreate all the config.

So in fact, I want to implement the flow mentioned in this topic in an Home Assistant Automation.

Any suggestions on how to do this? I am completely new to writing automations. I was able to generate some code with ChatGPT, but it’s not working really well at all.

Thanks for your pointers!