I understand the YAML allows this, and thus it doesn’t make sense to have “this” global. But I’m trying to get a clear understanding:
What was the use-case in mind to allow multiple sensors to share a trigger? Is there an advantage of this vs. having the switch defined separately and use the same trigger or (perhaps more likely) have the switch trigger off of sensor.sensor_one state change?
Can a template in the switch: block reference updated states('sensor.sensor_one')? Is there an order of processing of the various entity domains listed?
I guess this is easy to test, but does using unique_id on the config block and no unique_id in the entity block result in _1 and _2 unique ids?
I know this has been discussed elsewhere but I still find it unintuitive that keys of attributes work as (and thus override) variables of the same name. (When I want to reference an attribute multiple times I define it in variables.)
So, by inconsistent it means you can’t depend on the behavior? Therefore, don’t reference the other entities.
No, I meant when you do a config-level unique_id. I always add mine to the sensor block, but then saw that example where it was at the config-level only. Maybe that was just an incomplete example?
template:
- unique_id: my_unique_id
sensor:
- name: sensor one
switch:
- name: switch one
where the entity doesn’t have a unique id what ends up on the entities if they share the config-level one. The docs says for the config-level one: “This is prefixed to all unique IDs of all entities in this block.”
I think I have a good example where this works well: a Modbus sensor that reads a large amount of data at once (say, battery data + solar panel data). It’s then very natural for two template sensors to be under a single state trigger for that Modbus sensor.