Hey everyone, I have been looking for a generic script to trigger my alarm system when two or more sensors activate at the same (period of) time.
So far I have tried this and no luck:
I have tried to write a code myself, but I can’t get the grip of it.
Anyone has come across a good script or can give some pointers to write one.
I follow. I try to add this to the trigger section but my lack off expirence wont let me. Can you give me a little help once again? I fail to indent and I keep getting all sort of errors. I still have huge problems when is in splited files like binary_sensors.yaml.
trigger:
- platform: state
entity_id:
- binary_sensor.motion_arriba_occupancy
to: "on"
- platform: state
entity_id:
- binary_sensor.motion_cocina_occupancy
to: "on"
- platform: state
entity_id:
- binary_sensor.motion_comedor_occupancy
to: "on"
- platform: state
entity_id:
- binary_sensor.motion_hall_occupancy
to: "on"
- platform: state
entity_id:
- binary_sensor.motion_living_occupancy
to: "on"
- platform: state
entity_id:
- binary_sensor.motion_escalera_occupancy
to: "on"
- platform: state
entity_id:
- binary_sensor.motion_pieza_occupancy
to: "on"
Legacy format
This is the way you have configured your Template Sensors and is the traditional, or “legacy”, method. The configuration of legacy method Template Sensors is placed under the sensor: key.
Modern format
This is the new way of configuring a Template Sensor and it is placed under the template: key (not the sensor: key). Its option names are different from legacy method. Although Home Assistant accepts Template Sensors configure din either legay or modern format, only the modern format can be used to configure a Trigger-based Template Sensor, not the legacy method.
Here is binary_sensor.pir_cross_sensor defined as Trigger-based Template Sensor in modern format. Add it to configuration.yaml file. However, if your configuration.yaml file contains template: !include templates.yaml then add it to templates.yaml (but in that case, remove the first line shown below).
For more information, I recommend you review the documentation for Template Sensor, especially the initial section describing the new way of configuring them.