Alarm with multiple sensors

Hello,

My alarm system has several detectors on the same floor, and I want to create “something” for this group of sensors.
“Something” is in my mind a variable, but I struggling with how to best use the HA framework.

The desired functionality is to create a new “variable” floor_active as follows:

  • When any of the sensors are “1” I want floor_active to also become “1”
  • When all sensors have been “0” for 5 minutes, I want floor_active to become “0”

First I need something to store the floor_active state. Should I go for creating an “input_text” or something else?

Next I need to create the automation. Something similar to below?

configuration.yaml:

input_text:
  floor_active:
    name: floor_active
    initial: Some Text

automation.yaml:

alias: 'Floor idle'
trigger:
  - platform: state
    entity_id:
      - sensor.sensor1
      - sensor.sensor2
      - sensor.sensor3
    to: '0'
    for:
      Minutes: 5
action:
  service: input_text.set_value
  data_template:
    entity_id: input_text.floor_active
    value: '0'

alias: 'Floor active'
trigger:
  - platform: state
    entity_id:
      - sensor.sensor1
      - sensor.sensor2
      - sensor.sensor3
    to: '1'
action:
  service: input_text.set_value
  data_template:
    entity_id: input_text.floor_active
    value: '1'

At the moment “floor_active” gets set to “1” when any sensor is active, but never goes back to “0”.

Any help/direction is appreciated. Perhaps there are components which do this kind of functions already.

Thank you

Create an input_boolean. It will be used to indicate the state of all sensors.

input_boolean:
  floor_active:
    name: floor active

Create a group containing all sensors.

group:
  floor_sensors:
    entities:
      - sensor.sensor1
      - sensor.sensor2
      - sensor.sensor3

Create two automations.

  • The first one enables the input_boolean when the group is on.
  • The second one disables the input_boolean when the group is off for at least 5 minutes.
automation:
- alias: 'floor sensor active'
  trigger:
  - platform: state
    entity_id: group.floor_sensors
    to: 'on'
  action:
  - service: input_boolean.turn_on
    entity_id: input_boolean.floor_active

- alias: 'floor sensor all inactive'
  trigger:
  - platform: state
    entity_id: group.floor_sensors
    to: 'off'
    for: '00:05:00'
  action:
  - service: input_boolean.turn_off
    entity_id: input_boolean.floor_active

Thank you - this helped me in the right direction!