New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For function timer on Events: state node being incorrectly reset. #277
Comments
How should the timer logic be handled after the node has been triggered for being greater than 400 for 5 minutes?
I'll probably have to look at how HA handles that to keep them similar. |
I see what you're getting at, and I also didn't know how HA would handle a similar automation, so I ran some tests. I created an input_number in HA's helpers panel with a range of 0 to 100, and setup a simple automation around it. TriggersTrigger type: Numeric state ActionsAction type: Call service Basically, if I set the input_number to a value above 20 and leave it there for ten seconds, I get a notification on my phone. I then proceeded to test the automation in the various execution modes (Single, Restart, Queued, Parallel). In all configurations, if I set value above 20, I'd get the notification ~10 seconds later. If I then set the value to another setting above the threshold, I would not get a notification. If I set it below the threshold, and then set it back above, I would then get a notification. Based on this, it seems as though the automation engine in HA conforms to the second bullet point, in that a new timer is not started until the condition is false and subsequently becomes true again. The only conditions under which I got a notification after setting the input_number value to an above threshold number from and above threshold number, was after having made a change to the automation and hitting the save button. If you're interested in my actual real-world chains, they're included below.
|
Yes, my tests show the same thing. I see that you're using the hass.io addon if you want to test these changes before the next release of the addon you can add the following to the node-red addon config and it will install the latest version of this package once it has been updated on npm. npm_packages:
- node-red-contrib-home-assistant-websocket@latest |
The very definition of agile development. Enjoy some coffee on me. |
Describe the bug
I have a chain setup to perform actions when the wattage on a computer plug rises above a certain threshold for a given amount of time. Prior to v0.27.0, I did by setting an appropriate "If State" parameter on the
events: state
node and piping the'If State' is true
output to a delay node. After v0.27.0, I switched to using the new for condition on theevents: state
node, however I found that I was not getting the same functionality that I previously had.What seems to be happening is that the for condition timer is being reset every time the truthiness of the if state is being evaluated as state value changes occur, even if the if state condition remains true.
To Reproduce
Steps to reproduce the behavior:
events: state
node for an entity that reports a numerical value, such as aninput_number
entity.> $threshold
configuration, for example> 10
5 minutes
.input_number
entity to be above the threshold, say12
if you used the threshold from step 2.events: state
node showswaiting for 5 minutes: <timestamp>
input_number
entity to another value that is still above the threshold.events: state
node still showswaiting for 5 minutes: <timestamp>
, but that the timestamp has changed. and is now five minutes from the time theinput_number
entity was last updated, indicating that it has been reset even though the if state was not false.Expected behavior
The behavior I'm expecting is that the timer would continue counting down from the point at which the if state originally became true and would not be reset in the event of a state change that still evaluated as true.
As it stands now, for nodes that evaluate a sensor that monitors wattage, where the value can change quite often, and still remain above the if state threshold, the node will never issue a message unless a timer value is chosen that is less than the refresh rate of the sensor, which would be sub-optimal.
Screenshots
An
events: state
node configured to monitor a wattage sensorThe node waits to emit a message for five minutes when the sensor value is above threshold.
The time stamp on the node status continues advancing as the wattage sensor continues updating, even though the reported value continues to be above threshold.
Example Flow
Environment (please complete the following information):
Other (please complete the following information):
Additional context
None.
The text was updated successfully, but these errors were encountered: