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

Previous Value No Longer Working #553

Unanswered
okkine asked this question in General
Discussion options

I have some state triggers that use the previous value (.old). A couple months ago they just stopped triggering, and I can't seem to figure out what's changed.

I've used
@state_trigger("sensor.circadian_on_off > '0.0' and sensor.circadian_on_off.old == '0.0' ", state_hold=5, kwargs= {"rooms": rooms})

@state_trigger("sensor.circadian_on_off > 0.0 and sensor.circadian_on_off.old == 0.0 ", state_hold=5, kwargs= {"rooms": rooms})

@state_trigger("sensor.circadian_on_off > '0' and sensor.circadian_on_off.old == '0' ", state_hold=5, kwargs= {"rooms": rooms})

@state_trigger("sensor.circadian_on_off > 0 and sensor.circadian_on_off.old == 0 ", state_hold=5, kwargs= {"rooms": rooms})

Has something broken in a recent update? Or am I missing something here?

You must be logged in to vote

Replies: 1 comment

Comment options

If you want to trigger on the numeric value, it will be much more robust and reliable to convert to float and do a numerical (rather than string) comparison. So it's better to do this:

@state_trigger("float(sensor.circadian_on_off) > 0 and float(sensor.circadian_on_off.old) == 0", state_hold=5, kwargs= {"rooms": rooms})

One debugging approach is to add a debug function that triggers off any state change, eg,

@state_trigger("sensor.circadian_on_off")

and then logs the values of sensor.circadian_on_off and sensor.circadian_on_off.old. That way you can confirm the values are what you expect. You could even log the value of the trigger expression too, eg:

@state_trigger("sensor.circadian_on_off")
def debug_circadian_on_off(var_name=None, value=None, old_value=None):
 log.info(f"debug_circadian_on_off var={var_name}, value={value}, old_value={old_value}, trig={float(value) > 0 and float(old_value) == 0}")
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

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