Unable to keep @state_triggers running. #183
Replies: 1 comment
-
I ran the following test repeatedly with success. I imported your function, changing only the trigger variable to match one of mine: On my Lovelace control panel I toggled input_boolean.sunshading_active, which triggered the function and created log messages repeatedly. Note that with the " == 'on'" test, it will only trigger when changing state from 'off' to 'on', not the reverse. I HAVE had a situation that seemed similar to what you describe, but upon investigation of the log file I discovered the trigger had invoked code that had terminated with an error, causing Pyscript to stop running. |
Beta Was this translation helpful? Give feedback.
-
So, I've started using pyscript recently and one thing that always seems to get me is that my @state_trigger functions get called once and then they basically never respond again. I've had success with @mqtt_trigger functions (which I might just use instead), but I'd like to be able to get @state_trigger working properly.
My setup: HA core-2021.2.3 and pyscript 1.3.1 (HACS install).
This is a simple script that I wrote that should trigger off a group of 2 motion sensors:
`
@state_trigger("group.kitchen_motion_sensors == 'on'")
def kitchen_lights(**kwargs):
task.unique("kitchen_lights")
log.info(f"Triggered; turning on the kitchen lights with {kwargs}")
If I'm understanding correctly,
group.kitchen_motion_sensors
is a valid state trigger target as it exposes 'on' or 'off'. However, I have the same issue when it comes to usingbinary_sensor.kitchen_motion_sensor_1
.Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions