For more then 2 years now i am using a hardware modified xiaomi round buttons behind my Gira switches. I designed a special holder for this (see:https://www.thingiverse.com/thing:3508223 )
Currently i am using the xiaomi mija gateway and the older integration. That integration has support for a longpress event, which i am using in several automations.
I am now investigating moving my zigbee devices (Ikea lights and xiaomi stuff) to the new Sonoff Zigbee Gateway (modified so it can be used in homeassistant) with ZHA.
It appears that the ZHA integration only expose the raw events and doesnât have a longpress event implemented for the xiaomi round switch. (Lumi.sensor_switch in ZHA).
With the new release of core 0.115.x there is now a âwait_for_triggerâ available in the actions, that makes it much easier and nicer to implement this without âhelpersâ.
I therefore share my solution for those who are facing the same problems.
Replace the <device_ieee> with your id.
Is is very easy. The above script generates 2 events(Shortpress and Longpress). You have to create an automation, with a trigger who listens to the event.
@jodur, any ideas on how to modify the automation to accept multiple buttons? I was about to create a new automation for each button I have but feel like there would be a way to template this, just cant work out how!
You could use the new âBlueprintsâ feature for this. There was already somebody who made a blueprint for the normale events for the Miija round button, so i suggested him to add the longpress from my example.
(see: https://community.home-assistant.io/t/zha-xiaomi-mijia-round-wireless-switch-wxkg01lm-lumi-sensor-switch/258472 )
I didnât receive any feeback on it. Maybe if i have some time left over this weekend, i will do it my self to implement this. Coudnât be that difficult, only have to do some more detail reading on blueprints.
Many thanks for your contribution which indeed is really helpful for those with the 1st gen Xiaomi buttons.
I tried to make an automation based on this topic for long-press and release function of the button to dim or brighten a light using an input_boolean. You can see my almost working yaml here.
The thing is that the dim/brighten automation was initially based on the Xiaomi integration which exposed the long-press and release functions but after reading your post I understood why it is not working with my config (I am using the buttons through the ZHA integration which obviously does not support the long-press event).
It would be super helpful if you had the time and could help with this dim and brighten automation using the way you discovered above. I tried to do it myself but unfortunately I am not getting any results.