How to refer to entity when using entity_id in binary_sensor template?

Hi,

I’m trying to combine twelve Xiaomi leak sensors into one using a binary sensor template. I’ve seen lots of examples of referring to each sensor one at a time, but to keep things easier to manage, I’d like to keep a list of the sensors in a separate file and include it as needed in various parts of HA.

When using entity_id to provide a specific list of entities, how does one actually refer to the entity in the value template? I haven’t seen any examples of this. This is what I’ve got:

binary_sensor:
  - platform: template
    sensors:
      water_leak:
        friendly_name: "Water Leak"
        device_class: moisture
        entity_id: !include water_sensors.yaml
        value_template: “{{ is_state(‘entity’, ‘on’)}}”

This will not work, i think.
But it’s easier to add your sensors to a group, and if one sensor is on, the group is on.

Does using a group still allow the ability to report which sensor in the group is triggering?

1 Like

+1 I also have this question.
I have several leak sensors, and it seems quite repetitive and unnecessarily complex to setup N alerts for N sensors.
Ideally alert could just take a list of entities to watch state for - this seems like a simple and straightforward solution - but that doesn’t seem possible with the way alerts work today?
So using a “template” binary sensor seems to be the go-to solution for this sort of thing - but again, it requires maintaining a list of all the sensor entity ids in a value_template, which also seems repetitive.
Wonder if there is a way to reference a “wildcard” of sensors in a straightforward way, such that adding sensors with a certain naming convention, or even device_class, etc can be automatically covered by the alert/template-sensor/automation/etc, without needing to manually update multiple references each time we add the nth sensor of some existing type.