Making Home Assistant’s Presence Detection not so Binary

Hi, let me start with I love this blueprint, though I am just wondering, I drive past my house sometimes for work as I’m on the road all day, and even though I’m not going in the presence will change from away, to just arrived and then back to just left the back to away again, is there any way of putting a time limit on the away section, so if home assistant triggers home, it would wait in away for 2 minutes before switching to just arrived, if I happen to leave before that time then it wouldn’t change at all
The only other way I can think of working around this is by adding a timer for 2 minutes and if that’s active nothing gets triggered
Thanks

1 Like

Hi @ cliffordwhansen,

Great addition and template.

Could you update your post to remind people that HA is case sensitive. I had a fun time trying to figure out why things were not working well until I realized there’s a big difference between “Just Arrived” and “Just arrived”. Not everyone has natually capitalizes every word. Since users have to set up their own helper, noting this up front may help avoid silly mistakes like mine.

For other reading this commnet: Make sure your helper is capitalized just like shown in the image.

Thanks.

1 Like

Hello @cliffordwhansen,
Thanks for the awesome blueprint! I’ve been using it for some time now and want to extend it a little bit further with things like ‘Sleeping’. I’ve tried to edit your blueprint, but HA keeps giving errors. Could you help me where I made the edits wrong?
I want to use the Android companion app sensor ‘sleeping confidence’, which looks quiet accurate.
I’ve added the following input:

  • sleeping confidence (sensor value for nummeric state trigger)
  • time_till_marked_sleeping (for what time the sleeping confidence should be above the required value)
  • slider_sleeping_confidence (to choose the trigger value)
blueprint:
  name: 'Person: Status Update V2'
  description: Making Home Assistant’s Presence Detection not so Binary
  domain: automation
  input:
    person_device_tracker:
      name: Device tracker
      description: This is the device tracker for the person
      selector:
        entity:
          domain: person
    person_input_select:
      name: Input select
      description: This is the input select that tracks the person's status
      selector:
        entity:
          domain: input_select
    sleep_confidence:
      name: Sleep confidence HA app
      description: Uses to verify if somebody is asleep
      selector:
        entity:
            domain: sensor
    time_till_marked_away:
      name: Time till marked away
      description: How long to wait in just left before getting set as away
      default: 10
      selector:
        number:
          min: 0.0
          max: 60.0
          unit_of_measurement: minutes
          mode: slider
          step: 1.0
    time_till_marked_home:
      name: Time till marked home
      description: How long to wait in just arrived before getting set as home
      default: 10
      selector:
        number:
          min: 0.0
          max: 60.0
          unit_of_measurement: minutes
          mode: slider
          step: 1.0
    time_till_marked_extended_away:
      name: Time till marked extended away
      description: How long to wait in away before being set to extended away
      default: 24
      selector:
        number:
          min: 0.0
          max: 168.0
          unit_of_measurement: hours
          mode: slider
          step: 1.0
    time_till_marked_sleeping:
      name: Time till marked sleeping
      description: How long to wait before somebody is marked as sleeping
      default: 10
      selector:
        number:
          min: 0.0
          max: 59.0
          unit_of_measurement: minutes
          mode: slider
          step: 1.0
    slider_sleeping_confidence:
      name: Sleeping confidence value
      description: The confidence of the Android app if somebody is sleeping
      default: 75
      selector:
        number:
          min: 0.0
          max: 99.0
          unit_of_measurement: percentage
          mode: slider
          step: 1.0
  source_url: https://gist.github.com/cliffordwhansen/aa993e4173d2ce2e44fc6a0cb0af3599
alias: 'Person: Status update'
description: ''
trigger:
- platform: state
  entity_id: !input 'person_device_tracker'
  to: home
  id: device_tracker_home
- platform: state
  entity_id: !input 'person_input_select'
  for:
    minutes: !input 'time_till_marked_home'
  id: input_select_wait_arrived
  to: Just Arrived
- platform: state
  entity_id: !input 'person_input_select'
  from: Just Left
  to: Just Arrived
  id: input_select_debounce
- platform: state
  entity_id: !input 'person_device_tracker'
  from: home
  id: device_tracker_not_home
- platform: state
  entity_id: !input 'person_input_select'
  to: Just Left
  for:
    minutes: !input 'time_till_marked_away'
  id: input_select_wait_left
- platform: state
  entity_id: !input 'person_input_select'
  to: Away
  for:
    hours: !input 'time_till_marked_extended_away'
  id: input_select_wait_away
- platform: nummeric_state
  entity_id: !input 'sleep_confidence'
  above: !input 'slider_sleeping_confidence'
  for:
    minutes: !input 'time_till_marked_sleeping'
  id: device_tracker_sleeping
condition:
- condition: template
  value_template: '{{ trigger.to_state.state != trigger.from_state.state }}'
action:
- choose:
  - conditions:
    - condition: trigger
      id: device_tracker_home
    - condition: state
      entity_id: !input 'person_input_select'
      state: Just Left
    sequence:
    - service: input_select.select_option
      target:
        entity_id: !input 'person_input_select'
      data:
        option: Home
  - conditions:
    - condition: trigger
      id: device_tracker_home
    sequence:
    - service: input_select.select_option
      target:
        entity_id: !input 'person_input_select'
      data:
        option: Just Arrived
  - conditions:
    - condition: or
      conditions:
      - condition: trigger
        id: input_select_wait_arrived
      - condition: trigger
        id: input_select_debounce
    sequence:
    - service: input_select.select_option
      target:
        entity_id: !input 'person_input_select'
      data:
        option: Home
  - conditions:
    - condition: trigger
      id: device_tracker_not_home
    sequence:
    - service: input_select.select_option
      target:
        entity_id: !input 'person_input_select'
      data:
        option: Just Left
  - conditions:
    - condition: trigger
      id: input_select_wait_left
    sequence:
    - service: input_select.select_option
      target:
        entity_id: !input 'person_input_select'
      data:
        option: Away
  - conditions:
    - condition: trigger
      id: device_tracker_sleeping
    sequence:
    - service: input_select.select_option
      target:
        entity_id: !input 'person_input_select'
      data:
        option: Sleeping
  default:
  - condition: trigger
    id: input_select_wait_away
  - service: input_select.select_option
    target:
      entity_id: !input 'person_input_select'
    data:
      option: Extended Away
mode: queued

I like this idea, what are the errors you are getting?

It doesn’t load my blueprint/automation:

Logger: homeassistant.components.automation
Source: components/automation/init.py:280
Integration: Automatisering (documentation, issues)
First occurred: 10:16:01 (1 occurrences)
Last logged: 10:16:01

Blueprint Person: Status Update V2 generated invalid automation with inputs OrderedDict([(‘person_device_tracker’, ‘person.roel’), (‘person_input_select’, ‘input_select.status_roel’), (‘sleep_confidence’, ‘sensor.mobieltje_roel_sleep_confidence’), (‘time_till_marked_away’, 20)]): Invalid platform ‘nummeric_state’ specified. Got <homeassistant.components.blueprint.models.BlueprintInputs object at 0x7f6aa17f3340>

I’ve also tried it without the extra ‘action’ part of the sleeping extension, but that gave the same results. So somewhere I’ve made an error with one (or more) of the 3 input variables I guess?

EDIT: Ah my bad, didn’t properly read the error. the nummeric state has a type (needs to be numeric state). It seems to be working now!

1 Like

Just out of curiosity, has anyone checked the proximity entity?

Initially I didn’t see anything wrong, but the error told me that platform should be numeric_state

I havn’t used it in automations yet, but have it showing on my main dashboard (currently I’m 16kms from home), and using the Waze Travel Time integration I have time to get home
image

Code for this block can be found here

1 Like

Yeah, I just saw it. It is working now :slight_smile:

1 Like

Sometimes we just need a second set of eye :wink:

Would you mind sharing the yaml for how you’ve put this in your dashboard like this?

I got it from someone on this platform, can’t remember who or where, but I have created a gist

1 Like