I have to know the desired state of the target sensor and they must be all the same, for example if I target temperature sensor I cannot trigger when any of them report a change in temperature and then further decide followup actions based on areas they are in.
The trigger will only work when the first sensor goes into desired state, because if a second sensor goes into descired state, the template will still return true and the trigger won’t fire again.
I wonder how can I workaround these limitations? Suggestions appreciated.
If you need to know which one of the moisture sensors turned on, you’ll need to list them individually in a State Trigger. There’s no simple workaround in this situation.
If you don’t need to know which one turned on, just that one of them turned on, create a Template Sensor that reports the number of moisture sensors that are currently on (your existing template already does that, just remove the final 'greater than zero '). Use it in a State Trigger to detect whenever the Template Sensor’s value changes.
It seemed the official doc says non-zero number are treated equally as true. Automation Trigger - Home Assistant(-,a%20non%2Dzero%20number,-or%20any%20of
If you create a Template Sensor that reports the number of moisture sensors that are currently on (sensor.moisture_quantity), it can be used in a State Trigger. However, like I mentioned in my previous post, you won’t be able to easily know which one just turned on (when more than one moisture sensor is on).
alias: example
description: Notify whenever another moisture sensor turns on
trigger:
- platform: state
entity_id: sensor.moisture_quantity
to:
condition:
- "{{ trigger.to_state.state | int(0) > trigger.from_state.state | int(0) }}"
action:
- service: notify.persistent_notification
data:
message: >
There are {{ trigger.to_state.state }} moisture sensors that are on.
If neither of my two suggestions meets your needs, you’ll have to compromise on your requirements (or, if you are a software developer familiar with python, submit a PR to the Core repository that modifies the State Trigger’s operation).