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
2021.7: changes to entities in numeric_state above/below are ignored #52784
Comments
This is also the case for numeric state conditions using input number helpers. |
It kinda makes sense and kinda doesn't make sense. But I see the use case. The thing is, the entity_id is the trigger and created the from->to states, while above/below are conditions.
In this case, It becomes even harder when talking about templates in this case. IMHO, we should document how this works. More importantly, how to write automation that work with this :) For example, I generally almost never put conditions in my triggers. I just trigger, and later figure out if it should run or not. - alias: Test
id: b9fd928a-8749-428c-92d2-1540da5cb424
trigger:
- platform: state
entity_id:
- input_number.test_sensor
- input_number.test_threshold
condition:
- condition: numeric_state
entity_id: input_number.test_sensor
below: input_number.test_threshold
action:
- service: light.turn_on
target:
entity_id: light.front_lights ☝️ In this example, it will trigger on either change and still only run the automation when the condition matches. But considering the examples in your report, you can go one step further: - alias: Test
id: b9fd928a-8749-428c-92d2-1540da5cb424
trigger:
- platform: homeassistant
event: start
- platform: event
event_type: automation_reloaded
- platform: state
entity_id:
- input_number.test_sensor
- input_number.test_threshold
action:
- choose:
- conditions:
- condition: numeric_state
entity_id: input_number.test_sensor
below: input_number.test_threshold
sequence:
- service: light.turn_on
target:
entity_id: light.front_lights
default:
- service: light.turn_off
target:
entity_id: light.front_lights So, in this example, it triggers is either the sensor or the threshold changes and corrects the light state using a choose. So this combines the two automations into a single one. The cool thing about this method, is that multiple things can trigger it, for example, the startup of Home Assistant or when automation is reloaded (e.g., when you changed something). This will correct the state of the front lights to be correct when you change something or after Home Assistant has been offline (and missed the trigger) as well. The downside of this, is of course, you'll trigger stuff more often (which in general isn't a problem). If it is, the only solution is to add to use your original automation, but with an added trigger for the reverse of the entities. |
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. |
The problem
When an entity is used in a
numeric_state
trigger'sabove
orbelow
declaration, changes to that entity do not result in the trigger firing when it seems logical that it should.Example automation included below.
Moving the
test_sensor
across thetest_threshold
value correctly triggers the automations; but moving thetest_threshold
across thetest_sensor
value does nothing.I would have expected moving the threshold to behave in the same way, otherwise I don't understand the point of the new feature.
What is version of Home Assistant Core has the issue?
2021.7
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Container
Integration causing the issue
No response
Link to integration documentation on our website
https://www.home-assistant.io/docs/automation/trigger/#numeric-state-trigger
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
New feature in 2021.7. From the release notes:
Referencing other entities in triggers and conditions
A small, but possibly helpful, change to our script and automations. You can now reference other entities for the above/below values of numeric state triggers and conditions. Both sensors and number entities can be used.
The text was updated successfully, but these errors were encountered: