#Person Groups? Where did they go.

1 messages · Page 1 of 1 (latest)

ruby notch
#

Hi all / I’m trying to create a helper group for my family so that I can use it in conditions to note when someone is home vs no one is home. I can’t figure this out and ChatGPT keeps telling me to make a persons group but there’s no obvious way to do so.

Help? lol

fathom python
#

Someone at home vs nobody home is best handled by looking at the state of the home zone

#

ChatGPT is making things up

ruby notch
#

For some reason when I tried using the home zone it wouldn’t trigger - I tried setting the trigger to when home zone was 0, but it never worked for me.

fathom python
#

Ok

#

You can check the state and see what's wrong

twilit geode
#

Could you share the yaml of the automation? And indeed, verify the state of zone.home.

gloomy lark
twilit geode
#

@gloomy lark If you make it in the UI it will already do to: "0"

gloomy lark
#

Yes, but not if you write it in YAML

ruby notch
# twilit geode Could you share the yaml of the automation? And indeed, verify the state of zone...

Thanks for everyone who replied! (sorry I don't know how to paste yaml into this in the properly formatted way...I'm just cut and pasting). I'm very new to all of this. Didn't ever get the zone thing figured out - but the work around for what I wanted was this automation that I put together with ChatGPT helping ....haven't been able to see if it runs in real life though.

alias: Vacation Mode Automation
description: ""
triggers:

  • trigger: time_pattern
    minutes: "0"
    conditions:
  • condition: template
    value_template: |
    {{ is_state('person.josh_burg', 'not_home') and
    is_state('person.christina', 'not_home') and
    states('input_datetime.vacation_start') != '' and
    (now() - as_datetime(states('input_datetime.vacation_start'))).total_seconds() > 86400 }}
  • condition: state
    entity_id: input_boolean.vacation_mode
    state: "off"
    actions:
  • parallel:
    • action: alarm_control_panel.alarm_arm_away
      metadata: {}
      data: {}
      target:
      entity_id: alarm_control_panel.alarm_control_panel
    • action: lock.lock
      metadata: {}
      data: {}
      target:
      entity_id: lock.back_door
    • action: climate.set_temperature
      metadata: {}
      data:
      hvac_mode: heat_cool
      target_temp_low: 65
      target_temp_high: 70
      target:
      entity_id: climate.thermostat
    • action: input_boolean.turn_on
      metadata: {}
      data: {}
      target:
      entity_id: input_boolean.vacation_mode
      mode: single
fathom dewBOT
#

To format your text as code, enter three backticks on the first line, press Enter for a new line, paste your code, press Enter again for another new line, and lastly three more backticks.
```yaml
example: here
```
Don't forget you can edit your post rather than repeatedly posting the same thing.

gloomy lark
#

what are you trying to achieve with this automation?

#

You want to arm the alarm, lock the door and set the temperature, when nobody is home, and the vacation has started for more than a day?

#
alias: Vacation Mode Automation
triggers:
  - trigger: state
    entity_id: zone.home
    to: "0"
  - trigger: time
    after: input_datetime.vacation_start
    offset: "24:00:00"
conditions:
  - conditon: state
    entity_id: zone.home
    state: "0"
  - condition: template
    value_template: >
      {{ now() - states('input_datetime.vacation_start') | as_datetime | as_local > timedelta(days=1) }}
  - condition: state
    entity_id: input_boolean.vacation_mode
    state: "off"
actions:
  - action: alarm_control_panel.alarm_arm_away
    target:
      entity_id: alarm_control_panel.alarm_control_panel
  - action: lock.lock
    target:
      entity_id: lock.back_door
  - action: climate.set_temperature
    data:
      hvac_mode: heat_cool
      target_temp_low: 65
      target_temp_high: 70
    target:
      entity_id: climate.thermostat
  - action: input_boolean.turn_on
    target:
      entity_id: input_boolean.vacation_mode
mode: single
ruby notch
#

Yes - exactly. When both persons are gone for 24 or more hours I want the actions you described to run. I see your new code - but does it look like the one that I posted will work also?

#
alias: Vacation Mode Automation
description: ""
triggers:
  - trigger: time_pattern
    minutes: "0"
conditions:
  - condition: template
    value_template: |
      {{ is_state('person.josh_burg', 'not_home') and
         is_state('person.christina', 'not_home') and
         states('input_datetime.vacation_start') != '' and
         (now() - as_datetime(states('input_datetime.vacation_start'))).total_seconds() > 86400 }}
  - condition: state
    entity_id: input_boolean.vacation_mode
    state: "off"
actions:
  - parallel:
      - action: alarm_control_panel.alarm_arm_away
        metadata: {}
        data: {}
        target:
          entity_id: alarm_control_panel.alarm_control_panel
      - action: lock.lock
        metadata: {}
        data: {}
        target:
          entity_id: lock.back_door
      - action: climate.set_temperature
        metadata: {}
        data:
          hvac_mode: heat_cool
          target_temp_low: 65
          target_temp_high: 70
        target:
          entity_id: climate.thermostat
      - action: input_boolean.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: input_boolean.vacation_mode
      - action: light.turn_off
        metadata: {}
        data: {}
        target:
          floor_id:
            - basement
            - downstairs
            - upstairs
mode: single
```yaml
#

to my understanding - this automation will check every hour and attempt to run as the trigger. Then for the conditions based on the input datetime it will check to make sure the input datetime is = or greater than 24 hours, it will also make sure vacation mode boolean is off. If these conditions are met - then it runs the 5 actions in parallel.

the input datetime Vacation Start has its own automation that when both persons leave the house it sets the datetime. that automation is this:

alias: Set Vacation Start Timestamp
description: ""
triggers:
  - trigger: state
    entity_id:
      - person.josh_burg
      - person.christina
    to: not_home
    from: home
conditions:
  - condition: template
    value_template: |
      {{ is_state('person.josh_burg', 'not_home') and
         is_state('person.christina', 'not_home') and
         (states('input_datetime.vacation_start') in ['', 'unknown', 'unavailable'] or
         (as_datetime(states('input_datetime.vacation_start')) < (now() - timedelta(hours=1)))) }}
actions:
  - action: input_datetime.set_datetime
    target:
      entity_id: input_datetime.vacation_start
    data:
      datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}"
mode: single
```yaml
twilit geode
#

just polling is rarely a smart solution. You could do:

description: ""
mode: single
triggers:
  - trigger: state
    entity_id:
      - zone.home
    to: "0"
    for:
      hours: 24
      minutes: 0
      seconds: 0
conditions: []
actions: []
ruby notch
#

Sorry thank you for helping - can you explain what you mean by just polling is not a smart choice? I’m not sure what just polling is / what you’re referencing.

twilit geode
#

polling = just regularly checking the value. So an analogy to the real world: smart is waiting for the doorbell, polling is just checking every minute if there is someone at the door. Aka in an automation:

triggers:
  - trigger: time_pattern
    minutes: "0"
ruby notch
#

Ah! Okay - that makes sense. I think the reason I set it up to check every hour was to avoid some edge cases where the date time input that is a condition would prematurely trigger the automation - since I only want it to run after 24 hours of us being gone.

twilit geode
#

The for will basically make it a delayed trigger. When a trigger with a for happens it will basically:

  1. set a trigger for the set for-time to actually trigger the automation
  2. set a trigger for a state change that when it changes to a state you don't want, to cancel above trigger

Only downside with a long for is that if you restart HA most sensors will turn to 'unknown' for a bit which is a state change as well. But as you're triggering for vacation that will probably not happen 😄 If you want to also cover that edge case it does get quite a bit harder...

fathom python
#

every minute would be

triggers:
  - trigger: time_pattern
    minutes: "/1"
twilit geode
#

@fathom python You're right! But it was more about the difference between event based and polling in general 🙂

ruby notch
#

Yeah so I did the polling to avoid the edge case issue where both people leave home but one of our phones dies and is offline for a while - and then goes back online. I wouldn’t want that to restart the calculation of how long we’re away.

#

So it just checks every hour and that way it sets the vacation mode actions pretty close to when we are actually gone for 24 hours - give or take an hour or so.

#

At least I think that’s why I did this 😅😅😅😅

ruby notch
#

My understanding was that if I set the trigger to people being away for 24 hours - this trigger would run one time at 24 hours and if someone's phone was offline, or not reporting info, then the actions wouldn't proceed and it wouln't try to run again. Doing a check every hour seemed to solve that issue where for example we take a dream vacation to New Zealand and are on a plane with our phones in airplane mode for like 20 hours and so we don't come back online until like...hour 30 or something. I'd still want the automation to run.

twilit geode
#

A person with an empty phone will not make the zone.home go up so not an issue. And based on the docs (https://www.home-assistant.io/integrations/person/) I think the state of the person will just stay the last one if that person has only a single tracker and it's empty/unavailable

Home Assistant

Instructions on how to set up people tracking within Home Assistant.

#

and zone.home is based on the state of the persons aka just counting how many have the state of the zone.