Use the switches in the house to trig the Alarm


I am looking to use the switches in the house (lights) to trigger the alarm. EX: If any of the home residents are not home and a light is turned on or off the alarm should be triggered.

Can you please help me set the trigger for this kind of idea?

PS: I am using the Shelly 1, 1PM and Dimmer 2.
Version HA: 2020.12.7
Operating System Home Assistant OS 5.9

Thank you!

What is the entity that represents your alarm system?

Also, what method are you using to detect if the house is occupied or not?

Here is a very preliminary example:

alias: example 1
- platform: state
  entity_id: group.my_lights
  from: 'off'
  to: 'on'
- condition: state
  entity_id: binary_sensor.house_is_occupied
  state: 'off'
- service: switch.turn_on
  entity_id: switch.your_alarm

Thank you for your help!

I tried to simplify the example, actually my idea looks like this:

Guest mode: off
Person 1: not home
Person 2: not home
Send Push notification to Person 1 with 2 options:
Option 1: Activate Alarm
Option 2: Ignore
Trigger: ???


alias: Notif Activity
description: 'Home activity: switches on'
  - platform: 
  - condition: state
    entity_id: input_boolean.guest_mode
    state: 'off'
  - condition: state
    entity_id: person.r2
    state: not_home
  - condition: state
    entity_id: person.r1
    state: not_home
  - data:
      message: Activity in your home. Turn on alarm?
      title: Stare
        clickAction: lovelace/panou-central
        color: green
        group: Stare
        importance: default
        persistent: 'true'
        sticky: 'false'
          - action: trigger_5
            title: Da
          - action: trigger_6
            title: Nu
    service: notify.mobile_app_radu_s
mode: single

Simply create a State Trigger and provide a list of entities that you wish to monitor:

- platform: state
  - light.first_light
  - light.second_light
  - switch.switch1
  from: 'off'
  to: 'on'

I was thinking on the situation when a light remained turned on… is there a possibility to use the toggle (change of state) option and also maybe to group the entire switches?

Then it wouldn’t trigger a false alarm. Because the from state is set to off.

This sounds different than what you described in your first post: detect when a light is turned on when no one is home. Do you still want that or do you want to know if a light was left on when the last person leaves the house? The two requirements are different.