-
Notifications
You must be signed in to change notification settings - Fork 58
Is it possible to react with Pyscript to a long press at a switch? #529
-
Is it possible to react with Pyscript to a long press on a switch?
The HA atomatization allows to specify a trigger "key long pressed".
Haven't found a way with pyscript yet unfortunately.
Some additional info:
- The Shelly uses the standard Shelly integration.
- ColoT is active.
- MQTT is off.
Any help would be appreciated!
Beta Was this translation helpful? Give feedback.
All reactions
You can but you need to know what events your device is firing first. What's your event provider? Is it Zigbee HomeAssistant (zha)?
In my case I was able to look at the event types coming from zha_event on this endpoint, http://homeassistant.local:8123/developer-tools/event and have my pyscript service fire on every event, then filter out the events I don't care about, and action on those I do care about.
This image shows the event fired from an Ikea Tradfri E1810 5 button remote.
I correlate remote to zha_event event via the device_id field, and the type of event (button up/down/press/hold) via a combination of command+args fields.
Replies: 1 comment 3 replies
-
You can but you need to know what events your device is firing first. What's your event provider? Is it Zigbee HomeAssistant (zha)?
In my case I was able to look at the event types coming from zha_event on this endpoint, http://homeassistant.local:8123/developer-tools/event and have my pyscript service fire on every event, then filter out the events I don't care about, and action on those I do care about.
This image shows the event fired from an Ikea Tradfri E1810 5 button remote.
I correlate remote to zha_event event via the device_id field, and the type of event (button up/down/press/hold) via a combination of command+args fields.
image
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks @JacobLChrzanowski !
The hint to use development tools->events has brought me further!
I concentrated all the time on States and ignored Events completely.
This realization works perfectly for my Shelly:
@event_trigger("shelly.click", "device == 'shelly1-XXXXXXXXXXXX' and click_type == 'long'")
def corridor_switch_longpress(**kwargs):
log.info("corridor_switch_longpress")
cover_open("all")
Beta Was this translation helpful? Give feedback.
All reactions
-
You got it!
Beta Was this translation helpful? Give feedback.
All reactions
-
I do something similar in my pyscript repo. Super WIP.
https://github.com/JacobLChrzanowski/HomeAssistant/blob/cbce3b1d5703c750a2df7261a7eb427a22f28b7d/CONFIG/pyscript/example.py#L383
Beta Was this translation helpful? Give feedback.