Better integrate Nest Away Mode

I’m looking for advice on synchronising Nest Away Mode and Home Assistant’s “is in home zone”.

There are two things attempting to track my home/away state:

  • Nest iOS app (and Nest thermostat/smoke alarm motion sensors) - Sets Nest Away Mode state
  • Home Assistant iOS app - Fires zone event when I arrive home

I have their state displayed in a card like so:

screenshot

I’m looking to synchronise these. I already switch off Nest Away Mode in my automation when the Home Assistant iOS app fires the zone event, in case it detects I’m home before Nest does.

- id: arriving_home
  alias: 'Arriving home'
  trigger:
    platform: zone
    event: enter
    zone: zone.home
    entity_id: device_tracker.alecs_iphone
  action:
    - service: nest.set_mode
      data:
        home_mode: home
    // lights etc.

But often Nest detects my presence (Nest Away Mode is switched off) before the Home Assistant iOS app does. So I think I need to essentially do the reverse of the above automation - fire a “Alec’s iPhone is home” event, if Nest Away Mode switches off when the Home Assistant iOS app thinks I’m not at home.

Any advice on achieving this automation, or perhaps I’m going about this in the wrong way?

I’ve discovered device_tracker.see which allows me to set the device tracker state manually and solve this.

My automation is as follows, which sets my device to “home” (triggering normal “Arrive home” automations) if Nest Away Mode is switched to off while HA thinks nobody is home.

- id: nest_trigger_home
  alias: 'Trigger arrive home from Nest'
  trigger:
    platform: state
    entity_id: binary_sensor.house_away # Nest Away Mode sensor
    from: 'on'
    to: 'off'
  condition:
    - condition: state
      entity_id: group.all_devices
      state: 'not_home'
  action:
    - service: device_tracker.see
      data:
        dev_id: device_tracker.alecs_iphone
        locaton_name: 'home'