Automatic turn on/off cameras when person change status

Hi,

I made an automation where my security camera automatic turn off when all persons leave the home. I have made it like this:

- id: '1717422963048'
  alias: Camera On
  description: ''
  trigger:
  - platform: state
    entity_id:
    - person.1
    - person.2
    from: home
    to: not_home
  condition:
  - condition: state
    entity_id:
    - person.1
    state: not_home
  - condition: state
    entity_id:
    - person.2
    state: not_home
  action:
  - service: camera.turn_on
    data: {}
    target:
      device_id:
      - Camera 1
      - Camera 2

If I make if the other way around the problems is that we both need to be home before camera turn off. Can someone help with an “or” function so the camera will turn off when one of us arrive home.

And if it is possible I would also like to include the the camera always should be on from 10pm to 7 am if someone is home.

Please read how to post a good question and format your code to be readable by everyone who may want to help you.

f6be36681e0da431418ec7781fb6c62712941803

You don’t need a condition to achieve that. Whoever arrives home first serves to trigger the automation and turn on the camera.

alias: example
trigger:
  - platform: state
    entity_id:
      - person.1
      - person.2
    from: 'not_home'
    to: 'home'
condition: []
action:
  - service: camera.turn_on
    target:
      device_id:
        - camera1_id
        - camera2_id

Whoever arrives home will trigger the automation and turn on the cameras. The cameras stay on until both people leave the house.

1 Like

Thank you very much, I have been looking at this for 2 days and then the solution is that simpel.

And I just made it active from 7 am - 22 pm, then the last question is solved.

1 Like