Home Occupancy Toggle via Unifi

Hi all,

I’m looking for some help to figure out why this automation isnt working.
Basically my goal is to Toggle a Home Occupancy input boolean to off when every member of the house is out.
And toggle it back on once at least 1 person is home.

This is what I have for my Home Empty but its not working:

alias: Home Empty
description: Toggle Home Empty switch when no one is Home
trigger: []
condition:
  - condition: state
    entity_id: person.x
    state: Away
    for: '00:00:30'
  - condition: and
    conditions:
      - condition: state
        entity_id: person.x
        state: Away
        for: '00:00:30'
action:
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.home_occupied
mode: single

I couldn’t figure out a good trigger, was hoping it would bypass this but guess not?
As I wanted the trigger to be for when everyone is out.

You can just create a group with the two persons. It will have the state away when both are away and home, when at least one person is home.

I literally just thought about that!

Let me test that out, thanks!

So I just tried that

alias: Home Empty
description: Toggle Home Empty switch when no one is Home
trigger:
  - platform: state
    entity_id: group.awesome_people
    from: Home
    to: Away
condition: []
action:
  - service: input_boolean.turn_off
    data: {}
    entity_id: input_boolean.home_occupied
mode: single

Still doesnt work… Home Occupied switch isnt going off.

So I ended up going about this differently.

I added Awesome People as a condition to the alarm enablement instead.

Think this is working.

Well for some reason it works as a condition.
But if I want to create an alarm based on away it doesnt work:

alias: Set alarm when away
description: ''
trigger:
  - platform: state
    entity_id: group.awesome_people
    from: home
    to: away
condition: []
action:
  - service: alarm_control_panel.alarm_arm_away
    data: {}
    entity_id: alarm_control_panel.yale_smart_alarm
mode: single

I’m so confused.

So this work to disarm.
Every time I change from Away to Home, this triggers and I can hear my alarm trying to disarm (even tho it wasnt armed)

alias: Disable alarm when home
description: ''
trigger:
  - platform: state
    entity_id: group.awesome_people
    to: home
condition: []
action:
  - service: alarm_control_panel.alarm_disarm
    data: {}
    entity_id: alarm_control_panel.yale_smart_alarm
mode: single

But doing the same just reverse will not arm it…
Why?!

It’s not_home instead if away.

1 Like

Ah awesome let me try that… thank you

You can see the real state name under Developer Tools -> States.

not_home worked!
My alarm triggered perfectly.

Thanks so much