Google Maps + Router device_tracker Bug

I am using Google Maps Location Sharing and fritz (router) as device tracker.
Now I have one issue. Sometimes Google Maps cant update the location and will keep the old location.

So if maps thinks I am away (stuck somewhere on a road as last location) it will try updating my known device “phone” to away. Now if I am at home fritz knows that and will update “phone” to home. Now around every minute maps will change home to away for a few seconds which triggers my automation do turn off all devices and thats not how it should work. Any ideas?

Configuration.yaml:

  - platform: fritz
    host: 192.168.178.1
    password: !secret fritzbox
    interval_seconds: 8
    consider_home: 30
    new_device_defaults:
        track_new_devices: False
  - platform: google_maps
    username: !secret gmaps_mail
    password: !secret google
    max_gps_accuracy: 1000
    new_device_defaults:
        track_new_devices: False

Automation.yaml:

  - alias: 'Turn off everything if nobody is at home'
    hide_entity: true
    initial_state: off
    trigger:
      - platform: state
        entity_id:
          - device_tracker.google_maps_phone
        from: 'home'
        to: 'not_home'
      - platform: state
        entity_id:
          - device_tracker.google_maps_girlfriend
        from: 'home'
        to: 'not_home'
    condition:
      condition: and
      conditions:
        - condition: template
          value_template: "{{ states.device_tracker.google_maps_phone.state != 'home' }}"
        - condition: template
          value_template: "{{ states.device_tracker.google_maps_girlfriend.state != 'home' }}"
    action:
      - service: light.turn_off
      - service: switch.turn_off
        data:
          entity_id: switch.fernseher
      - service: switch.turn_off
        data:
          entity_id: switch.sonoff_10446e326
      - service: switch.turn_off
        data:
          entity_id: switch.sonoff_10044bc6c
      - service: climate.set_away_mode
        data:
          entity_id: climate.wohnzimmer1
          away_mode: 'on'
      - service: climate.set_away_mode
        data:
          entity_id: climate.wohnzimmer2
          away_mode: 'on'
      - service: media_player.turn_off
        data:
          entity_id: media_player.wohnzimmer_mini
      - service: media_player.turn_off
        data:
          entity_id: media_player.schlafzimmer_mini

Known_devices.yaml:

google_maps_phone:
  hide_if_away: false
  icon:
  mac: AB:12:34:56:78:91
  name: Phone
  picture: photo.jpg
  track: true

google_maps_girlfriend:
  hide_if_away: false
  icon:
  mac: AB:12:34:56:78:90
  name: Girlfriend
  picture: photo.jpg
  track: true

It’s not really a “bug” per se. You’re just getting bit by the combination of the overly simplistic device_tracker “merging” feature of the device_tracker component and the fact that the google_maps device_tracker platform causes a device_tracker entity update even when it knows there is no new data (see its last_seen attribute.)

You might have better luck removing the mac parameter from the current entries in known_devices.yaml (and restarting so there will be four entries again - two for each of you), then using the new person component, using the pair of device_trackers (google_maps and router) for each of you. (I don’t use the person component, so I really don’t know if this will do it.)

Or, instead of the person component, you could try out my custom composite device tracker platform which I wrote specifically to deal with these types of problems. (You’d still need to separate the google_maps and router entries in known_devices.yaml as I described above.)

1 Like