Help needed with presence automation

I have the following automation to sense whether my wife and myself are home or not and switch the heating on or off accordingly. It works very well and I would like to add my kids to it, but they don’t have the app installed on their phones and I want to use ping detection, which I have already set up and is functioning, but I can’t figure out how to add it to the automation. The status of ping appears to be ‘connected’ or ‘disconnected’ but adding this to the automation doesn’t work.

- id: '1575231618454'
  alias: Thermostat - We're Not Home
  description: ''
  trigger:
  - entity_id: group.parents
    platform: state
    to: not_home
  condition: []
  action:
  - service: scene.create
    data:
      scene_id: before_leaving
      snapshot_entities:
      - climate.thermostat
  - data:
      entity_id: climate.thermostat
      preset_mode: away
    service: climate.set_preset_mode

- id: '1575233619529'
  alias: Thermostat - We're Home
  description: ''
  trigger:
  - entity_id: group.parents
    platform: state
    to: home
  condition: []
  action:
  - service: scene.turn_on
    data:
      entity_id: scene.before_leaving

group.parents looks like this:

parents:
  name: Parents
  entities:
    - device_tracker.life360_me
    - device_tracker.life360_wife

The kids group is set up like this:

kids_phones:
  name: Kid's Phones
  entities:
    - binary_sensor.phone1
    - binary_sensor.phone2

and the entry in configuration.yaml is:

  - platform: ping
    name: "phone1"
    host: 192.168.1.191
    scan_interval: 60
    
  - platform: ping
    name: "phone2"
    host: 192.168.1.87
    scan_interval: 60

Use Ping Presence Detection instead of the Ping binary sensor.

1 Like

This is only the state shown in the frontend. If you go to Developer Tools → States you will see “on” and “off” respectively.

I’ve changed to ping presence but it not functioning as expected.

I have these entries in configuration.yaml:

device_tracker:
  - platform: ping
    hosts:
      kid1: 192.168.1.191

  - platform: ping
    hosts:
      kid2: 192.168.1.87

and these as entries in groups.yaml:

heating_presence:
  name: Heating Presence
  entities:
    - device_tracker.life360_me
    - device_tracker.life360_wife
    - device_tracker.kid1
    - device_tracker.kid2

I have changed the triggers in automation to ‘group.heating_presence’ and when I set it to ‘not_home’ in Developer Tools the heating goes to ‘away’ mode as expected. When I set me or wife to ‘home’ then it comes back on, as expected, but setting either ‘kid1’ or ‘kid2’ to ‘home’ does not result in it coming on.

I think the config should be this:

device_tracker:
  - platform: ping
    hosts:
      kid1: 192.168.1.191
      kid2: 192.168.1.87

First monitor group.heating_presence and make sure it’s changing to 'home' or 'not_home' as you expect as you change the state of the individual device_tracker entities.

My thermostat definitely changes from ‘away’ to ‘none’ mode when either me or wife are set to home, but not when kids are

Ok, there appears to be some weird logic going on. If I set ‘group.heating_presence’ to ‘not_home’ then the thermostat goes into ‘away’ mode, as it should, then if I set ‘kid1’ to ‘home’ it does not come back on, which it should, but if I set ‘kid1’ to ‘not_home’ then it comes on!!

You’re looking at too much at the same time. Just look at the states of the device trackers and the group(s) on the STATES page. Once you have that working right then look at how the state of the group affects the automation.

I can see each individual entry in group ‘group.heating_presence’ going from ‘home’ to ‘not home’ as I set the tracker states, but the kids state goes back to ‘home’ after a brief time. I think the tracker must be updating the status from the pings, whereas the status of my and my wifes phone takes longer to update, hence I can see the thermostat status change on those but not on the kids. I think it may be working, but everyone would need to be physically away to be sure.