I’ve been trying to optimise my automations while I’m away but I’m not sure I’m really doing it the best way… I have a group called “Everyone” which has 2 users in it based off of mobile presense and I also have a switch called Holiday Mode which I manually switch on as a kind of failsafe. I thought about creating an “Alarm” switch which be based on those 2 to simplify conditions but I don’t think I need it, or how to do it.
I have a camera that I want to only record via Frigate while everyone is away or holiday mode is on. I can’t get my head around the right way to do it so any suggestion on if/how to do the consolidated “Alarm” setting or how to streamline this automation:
alias: Camera - Downstairs record when away
description: ""
trigger:
- id: "on"
platform: state
entity_id:
- group.everyone
to: Away
- id: "off"
platform: state
entity_id:
- group.everyone
to: Home
- id: "on"
platform: state
entity_id:
- input_boolean.holiday_mode
to: "on"
- id: "off"
platform: state
entity_id:
- input_boolean.holiday_mode
to: "off"
condition: []
action:
- service: switch.turn_{{ trigger.id }}
target:
entity_id: switch.downstairs_recordings
mode: single
Not fully clear on what you are trying to achieve. Your current automation will turn on/off recording when either you are both away or use the holiday switch. Ie if you have the holiday switch on and one of you comes home, it will stop recording.
What do you also mean by the alarm switch? Do you want to turn your alarm on when away/in holiday mode or you want to also set recording if the alarm is on?
got it, so basically do the thing if everyone is away UNLESS Holiday mode is on - just do it regardless.
Are you open to moving away from group.everyone - it’s much easier to use the numeric state of zone home > 0 = occupied? (that way if you ever adjust occupancy - guests, mom in law, it just works without editing groups.)
That sounds good, the group seems to be having some strange functionality at the moment anyway. Can you point me any documentation around zone states? I’ve not come across them before.
Here you go on the docs. Zone - Home Assistant (home-assistant.io)
You’re basically making a occupancy automation, based on zone >0 (the state of the zone entity will be an integer equal to the number of tracked person entities are in the zone)
Your logic boils down to two triggers - two one that handles the case of home / away and has a condition which ignores if that holiday switch is on… then another that specifically handles the case of turning on / off the record switch if the holiday switch is on. Whether this is in one compound automation or two distinct automations really gets to how you prefer your stuff arranged.
Would the first part be done via an automation or is there some other tooling in HA that would be better fit? Does this look overly complex? I know the condition is, I just do it that way to try and catch if the sensor is in an unknown state etc, probably completely unnecessary
alias: Alarm - Change condition unless on holiday
description: ""
trigger:
- platform: state
entity_id:
- zone.home
condition:
- condition: not
conditions:
- condition: state
entity_id: input_boolean.holiday_mode
state: "on"
action:
- if:
- condition: state
entity_id: zone.home
state: "0"
then:
- service: input_boolean.turn_on
target:
entity_id: input_boolean.alarm_mode
else:
- service: input_boolean.turn_off
target:
entity_id: input_boolean.alarm_mode
mode: single