Instant not_home status?

of course, after having said that, for the first time ever, my life360 CC fails on me…
all of a sudden I only see home/not_home in the more info window and the device_trackers won’t update.

I know the real Life360 traders are fine, as displayed in the dedicated app, and also on my second system…

what on earth could cause this all of a sudden…
did update yesterday to the latest version but things were fine after that, or so I believed… do we need to set new settings somehow @pnbruckner ? Ill hop over to your thread to keep things tidy.

I still use four trackers (life 360, google maps, apple homekit and my router). I use the composite for zone based automations away from home and for the composite I just use the two GPS based trackers that can track all zones not just home and away. For automatons such as coming home, after months and months of trying multiple approaches I ended up just adding all of them vs groups, Bayesian, composite, etc and have never looked back. It works 100% of the time. My main issue was maybe only 5% of the time, one tracker would bounce home/not home, and this would cause an issue, or for the Bayesian, it might take an extra 30 seconds for the required number of trackers to show as home, etc.

So I have an input_select for (home, away, night), and if any tracker goes to Home or On, I change that to home. As far as away I use the Bayesian sensors.

I have not had an issue in months. It may not be as streamlined as some people may like. But after so many failed attempts at the perfect presence sensor, this has been perfect for me

hearing what you say… but what exactly do you mean by this ‘adding all of them’

how do you do it, and what is your automation ?

Here is are my two automations for home and away. It’s just me and my wife.

##########################################
## Setting House Mode based on Presence ##
##########################################
- alias: Home Mode Leaving
  trigger:
  - platform: state
    entity_id: binary_sensor.people_home
    to: 'off'
    for:
      seconds: 15
  condition:
  - condition: numeric_state
    entity_id: sensor.ha_runtime_in_minutes
    above: 1
  - condition: state
    entity_id: input_select.house_mode
    state: 'Home'
  action:
  - service: input_select.select_option
    entity_id: input_select.house_mode
    data:
      option: 'Away'
  - service: input_select.select_option
    entity_id: input_select.security_system
    data:
      option: 'Armed (Away)'

- alias: Home Mode Arriving
  trigger:
  - platform: state
    entity_id:
      - input_boolean.paul_present
      - input_boolean.tracy_present
      - input_boolean.guests_present
    to: 'on'
  - platform: state
    entity_id:
      - device_tracker.paul_all
      - device_tracker.pauls_iphone_2
      - device_tracker.tracy_all
      - device_tracker.tracys_iphone_2
      - group.extra_device_trackers
    to: 'home'
  condition:
  - condition: numeric_state
    entity_id: sensor.ha_runtime_in_minutes
    above: 1
  - condition: state
    entity_id: input_select.house_mode
    state: 'Away'
  action:
  - service: input_select.select_option
    entity_id: input_select.house_mode
    data:
      option: 'Home'
  - service: input_select.select_option
    entity_id: input_select.security_system
    data:
      option: 'Disarmed'
  - service: input_boolean.turn_off
    entity_id: input_boolean.vacation_mode

Here are my two Bayesian sensors for my wife and I. I spent a good amount of time tweaking this to work best for me

 - platform: bayesian
   prior: 0.6
   name: Paul Presence
   probability_threshold: 0.92
#   device_class: presence
   observations:
   - entity_id: 'input_boolean.paul_present'
     prob_given_true: 0.8
     prob_given_false: 0.3
     platform: 'state'
     to_state: 'on'
   - entity_id: 'device_tracker.pauls_iphone_2'
     prob_given_true: 0.8
     prob_given_false: 0.3
     platform: 'state'
     to_state: 'home'
   - entity_id: 'device_tracker.pauls_iphone'
     prob_given_true: 0.8
     prob_given_false: 0.3
     platform: 'state'
     to_state: 'home'
   - entity_id: 'device_tracker.google_maps_118087885302155'
     prob_given_true: 0.8
     prob_given_false: 0.3
     platform: 'state'
     to_state: 'home'
   - entity_id: 'device_tracker.paul'
     prob_given_true: 0.8
     prob_given_false: 0.3
     platform: 'state'
     to_state: 'home'

 - platform: bayesian
   prior: 0.6
   name: Tracy Presence
   probability_threshold: 0.92
#   device_class: presence
   observations:
   - entity_id: 'input_boolean.tracy_present'
     prob_given_true: 0.8
     prob_given_false: 0.3
     platform: 'state'
     to_state: 'on'
   - entity_id: 'device_tracker.tracys_iphone_2'
     prob_given_true: 0.8
     prob_given_false: 0.3
     platform: 'state'
     to_state: 'home'
   - entity_id: 'device_tracker.tracys_iphone'
     prob_given_true: 0.8
     prob_given_false: 0.3
     platform: 'state'
     to_state: 'home'
   - entity_id: 'device_tracker.google_maps_11611223760034'
     prob_given_true: 0.8
     prob_given_false: 0.3
     platform: 'state'
     to_state: 'home'
   - entity_id: 'device_tracker.tracy'
     prob_given_true: 0.8
     prob_given_false: 0.3
     platform: 'state'
     to_state: 'home'

Here is the binary sensor I use to determine if anyone is home. I have a couple groups for frequent visitors like family, and also an input boolean I use when I have guests who dont have a presence sensor at my home

 - platform: template
   sensors:
     people_home:
       friendly_name: People Home
       device_class: presence
       value_template: >
         {{ is_state('group.primary_presence', 'on') or
            is_state('input_boolean.guests_present', 'on') or
            is_state('group.extra_device_trackers', 'home')  }}
       entity_id: group.primary_presence,input_boolean.guests_present,group.extra_device_trackers

and here are my groups

# Only for Primary People (aka Paul and Tracy)
primary_presence:
  name: Primary Presence for Routines
  icon: mdi:account-multiple
  view: no
  entities:
    - binary_sensor.paul_presence
    - binary_sensor.tracy_presence

# Add guests here who are staying over
extra_device_trackers:
  name: Guest Presence Sensors
  icon: mdi:account-multiple
  view: no
  entities:
    - device_tracker.carolsiphone
    - device_tracker.jimsiphone

I might be missing a little bit like the apple homekit, but its most things.

Then I use the away, home for my routines based on arrival and leaving

Edit: I will say this is also what has naturally evolved over a period of nearly a year. I’ve not gone back and tried to streamline this much, but I suspect it could be cleaned up a bit.

2 Likes

My solution to “instant away” or instantly at home is sort of star-wars. I have a wireless LAN controller that sends accounting starts and stops to a radius server when devices come and leave. The radius server sends a webhook to HA when both events happen. I haven’t found another reliable way to do this.

Wow, thanks for all the tips! Coming home is instantaneous, but it’s always leaving that annoys me the most. Might try ptdalen’s solution, but what’s the binary_senor.people and the sensor.ha_runtime?

Also, has anyone tried this. Looks promising, but a little confusing.

Is there also a node-red equivalent or no?

only solution for that might be the Bluetooth way. But if you want instantaneous, you’d have to be very careful for timing issues in the automation, since they tend to trigger constantly, and you need conditions to rule out false alarms.

that is very well possible, I use these to prevent overzealous actions:

condition:
  - condition: template
    value_template: >
      {{ trigger.to_state.state is not none and
         trigger.from_state.state is not none and
         trigger.to_state.state != trigger.from_state.state }}
  - condition: template
    value_template: >
      {% set zones = states.zone | map(attribute='name')|list %}
      {{trigger.to_state.state in ['home','not_home'] or
        trigger.from_state.state in ['home','not_home'] or
        trigger.to_state.state in zones or 
        trigger.from_state.state in zones}}
  - condition: template
    value_template: >
      {{ (now() - trigger.from_state.last_changed | default(0)).total_seconds() > 
                                        states('input_number.presence_timer')|int }}

based on my life360 sensors, my presence detection is perfect. Set to 200 meters to have a nice working distance, I get notifications when arriving home to set the night lights etc perfectly in time, and when my kids have reached the end of the street after leaving home (which takes about 30 seconds…)

good enough for me :wink: And I dont use the Bluetooth trackers, since they really cause stress on the system.

Can you expand on this? In what way do they stress the system?

sensor.ha_runtime is a component for HA. Basically I use this in most my automations so they dont trigger after a restart. So HA has to be up for at least one minute in my automation. I just found this easier for me than having to worry if a sensor might be unknown, on/off after a restart and then trigger something I really did not want triggered. It’s not “necessary” for the automation, just a preference

The binary_senor.people is shown above in my post, but the goal of that is to keep my “goodbye” routines from running when people other than my wife and I (Primary presence’s) are at the house. So I have three possible scenarios (check out the code above), that determine if someone is at the house.

  1. My wife and I (the usual)
  2. Guests present (it’s an input boolean). This is for people that do not have a presence tracker, ie “Guests”
  3. Extra device trackers are for people who visit often but dont live at the house. Parents, kids, etc.

I dont want my "goodbye routine running if my wife and I leave but my parents are at the house.

As far as instant not_home. That can be tricky. If you’re willing to have the occasional “goodbye” routine run while you’re sitting at home watching TV because your phone presence flipped quickly, or you disconnected from wifi because you put your phone airplane mode to fix an issue, etc. you can have instant_away.

My away runs about 2-3 minutes after I leave every time. I have not had a false away in a long time, nor have I had a false “I’m still home”.

Presence has probably been one of the things I’ve tried to refine for years (it was smartthings before HA), and I never had good success until I just accecpted that a single conglomerate of sensors was not going to work 100%(at least not for me)

Another possible option for “instantaneous” not_home, could be either a button, or an alexa/google home routine, that you set up. As you’re walking out the door, say “google/alexa, I’m leaving”, or something like that. Have that routine turn on an input boolean. Have that input boolean trigger an automation with a delay of how ever long you need to get out of the house.

yes, that is the most reliable way of setting your home in away mode :wink:

my homepage has those on a Tile;

48

either manually, and sets all kinds of automations in progress, or , well , automatically, based on device_trackers and other sensors.

I forgot to mention that, mostly because the OP wanted a way to

‘force devices as not_home instantly’,

which this won’t do of course. devices are in whatever state they are, and forcing them into a state they are not is not advisable imho… Only do that in the dev-state to test configuration settings now and then…

1 Like

I have found, as did many other users, that using the device_tracker Bluetooth takes its toll on the system. If you check the time it takes to load at startup you get a basic idea. In my setup, that platform takes over 150 seconds, while when no bluetooth is tracked the platform loads in 12-15 seconds.
After that, it seemed to interfere with my Hue setup a lot. I have 2 systems, a MQTT hub with the mosquitto broker and bluetooth loaded, and my main system, without those. The main system subscribes to topics of the broker on the hub system, and, via mqtt, reads several BT devices states.

All I can say is on the Hub system, my Hue hub and lights go unavailable all the time (while of course they are not, search the forum for this issue, and find plenty) and my main system has a rather solid Hue platform.

1 Like

You know, I missed the comment about forcing things away. Reading it again, it sounds like one big part of this is the time it takes the asus presence to set to away (much longer than bluetooth).
You can change the “consider_home” settting for your router to a much shorter period if you like.

What did not work about the consider_home? So the default for the scan rate looks to be 12 seconds, maybe set the consder home to 15 seconds. I’d think that the longest it would take to mark you away in that scenario would be 26 seconds.

Sure, I’ve experimented with that, but it really didn’t help me find the correct response time.

Using life360 and some groups gives me the added ‘security’ I am not home, right in front of my door, and away when I close my door behind me. As would be the case with BT.

Ive set a perimeter of 300 meters or so.
The idea someone can find my phone and walk the street and my phone notifying my Home is found frightens me somehow…

Interesting. Can you expand a bit what you mean by

Two questions.

  1. Can you give an example if when/why you’d want to be “not home” when you are at your door (other than someone finding your phone). And how you’d seperate a normal, It’s me and It’s a stranger with my phone
  2. What kind of logic do you use to determine that your door closing really means you’re leaving, and not just stepping outside.

Thanks!

Must confess I’ve built that before I had a semi-perfect automation presence tracking, and I wanted a manual Away mode. I can use it to set motion sensors, lighting scenes, sensors and switches etc etc. I set my motions sensors to sensitive in all rooms, when away, but low, when home and a sleep in some rooms, etc etc.
I now only use the Away Tile manually to test changes in the setup really. Of course it is highlighted when active, so it is a great eyecatcher as well. Especially when my home_mode_locked theme kicks in …

Door closing isnt taken literally in my Home (dont have door sensors or locks yet). Just a couple of guard dogs out of their cages… (have a dedicated automation for that too, to prevent motion detection notifications on their movements.)
57
05

What I meant was that I want to have some perimeter and time lag. couple of hundred meters, so an accendental mobile device loss isnt too harmful, and allow a Home unlock, simply by walking close enough to my home. Time lag, so I can walk the dog, leave the house alone for let’s say 15 minutes before Home is secured.

the logic is rather simple for that:

  - alias: 'Empty home for 15 minutes'
    id: 'Empty home for 15 minutes'
#    initial_state: 'on'
    trigger:
      platform: state
      entity_id: group.family
      to: 'not_home'
      for:
        minutes: 15
#    condition:
#      condition: template
#      value_template: >
#        {{ is_state('input_boolean.guest_mode', 'off')}}
    action:
      - service: script.uit_huis_locked
      - condition: template
        value_template: >
          {{ is_state('input_boolean.notify_presence', 'on')}}
      - service: notify.notify
        data_template:
          message: >-
            {{as_timestamp(now()) | timestamp_custom("%X") }}: 
            Emtpy House, securing the premises.

the called script does all kinds of things… :wink: And of course hits after my regular leave home script has already noticed no one is at home and do other stuff.

all makes perfect sense. Sounds like we both have about the same thoughts on presence, home/away, etc.

I like “home” to be triggered as fast as possible, which is why I chose not to use to break out each possible presence sensor vs combined/Bayesian. Once Someone (anyone) is home then Home mode is on. Other people/presence sensors coming home don’t make me “more Home”, haha. I have other automation for stuff that I care about individuals coming or leaving.

But for away, I don’t want “instant” (too many false aways), I do like “quick” though, which is why I use the Bayesian for the most part for that. My goodbye routine usually runs about 2-3 minutes after I leave if I’m driving.

yes, indeed. I’ve learned by experience that using a group for a person, consisting of various trackers, bayesian and others, and the life360 on its own can be used for finetuning notification and independent action. Life360 is rather swift, or quick if you want it to be, so notification makes sure you know everybody left. The groups (always a bit slower because the wifi tracker is in there…), or timing automation as I posted above, can be used for the delayed actions. Best of both worlds.

thats one of the things I have been searching for!.
sounds so easy, but which components is that? sensor.last_boot? And what is your template to have it in minutes? or do you use

- platform: uptime
    name: 'HA runtime in minutes'
    unit_of_measurement: minutes

Thats the one I use.

1 Like