Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is it possible to react with Pyscript to a long press at a switch? #529

Answered by JacobLChrzanowski
wrfz asked this question in Q&A
Discussion options

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!

You must be logged in to vote

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

Comment options

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

You must be logged in to vote
3 replies
Comment options

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")
Comment options

You got it!

Comment options

Answer selected by wrfz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /