I found a solution that works well for me – but it‘s not using HA automations.
Instead I installed the AppDaemon add-on and then the ControllerX „app“.
Everything is explained very good here: ControllerX
Then, via the File Editor add on I edited the /config/appdaemon/apps/apps.yaml
file and added this for my E1743 IKEA Trådfri button:
IKEA_Dimmer_Stefan:
module: controllerx
class: E1743Z2MLightController
integration: z2m
controller: sensor.ikea_dimmer_button_stefan_action
light: IKEA Tradfri am Bett rechts
But you find many examples on the ControllerX Examples page here: Examples - ControllerX
Hope this helps. Check this, too: ControllerX. Bring full functionality to light and media player controllers