New Google Home device tracker Component - Introduced in HA 0.83

@rhomb

That would be the way to go!

I think the biggest issue to the reliability of this component (ATM) is the number of Bluetooth devices that each google home scans and reports to HA. I have 100’s of device trackers that have shown up though this component. I’m sure this is having an impact on the components ability to track correctly. I have noticed since the list of devices has grown, the reporting and timeframe of detection has become quite unreliable.

I have no idea how to code or read the logs to confirm, so hoping someone can comfirm or has a solution

I not sure if a whitelist can be create to stop the known_devices.yaml from growing as mentioned by @dimmanramone

When I only had a handful of known devices, I would walk past the google home in my hallway and it would detect immediately. Now it does not register until after I have gone to another room or not at all!

I will test this theory by removing all the devices that have accumlated and report back!

Lots of potential here! you could use this as a follow me music player for instance!

1 Like

This seems to pick up dozens of devices, but none of them are my cars. Anyone able to get their cars picked up?

Wow! :astonished:, my mysql db totally borked after a total of 2635 devices (seriously, I “counted” using grep and pipe to wc -l) was added to known_devices after adding my Google Home and one Home mini just a few days ago.

This is running in docker with separate mariadb on an core i5 so i think it would have failed quicker on my old rpi3 setup.

First sign was that graphs would not update anymore and found that there was problems with the database in the logs:

sqlalchemy.exc.InvalidRequestError: Can't reconnect until invalid transaction is rolled back,

Fine ok, I’ll try dropping the database then I started up again and noticed “device_tracker.” in the new error:

2018-12-11 21:58:13 ERROR (Recorder) [homeassistant.components.recorder.util] Error executing query: (_mysql_exceptions.DataError) (1406, "Data too long for column 'event_data' at row 1") [SQL: 'INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (%s, %s, %s, %s, %s, %s, %s)'] [parameters: ('call_service', '{"domain": "group", "service": "set", "service_data": {"object_id": "all_devices", "visible": false, "name": "all devices", "entities": ["device_trac ... (113414 characters truncated) ... f85c96", "device_tracker.1921687171_544f03bf4da0", "device_tracker.1921687172_544f03bf4da0"]}, "service_call_id": "5fe12f596159453b8527d1b8ab7a46c1"}', 'LOCAL', datetime.datetime(2018, 12, 11, 20, 57, 16, 905916, tzinfo=<UTC>), datetime.datetime(2018, 12, 11, 20, 58, 13, 195335), '0264b3880188460386d6c7391d96663d', None)] (Background on this error at: http://sqlalche.me/e/9h9h),
        self.errorhandler(self, exc, value),
      File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler,
        raise errorvalue,
    _mysql_exceptions.DataError: (1406, "Data too long for column 'event_data' at row 1"),
        self.errorhandler(self, exc, value),
      File "/usr/local/lib/python3.6/site-packages/MySQLdb/connections.py", line 50, in defaulterrorhandler,
        raise errorvalue,
    sqlalchemy.exc.DataError: (_mysql_exceptions.DataError) (1406, "Data too long for column 'event_data' at row 1") [SQL: 'INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (%s, %s, %s, %s, %s, %s, %s)'] [parameters: ('call_service', '{"domain": "group", "service": "set", "service_data": {"object_id": "all_devices", "visible": false, "name": "all devices", "entities": ["device_trac ... (113414 characters truncated) ... f85c96", "device_tracker.1921687171_544f03bf4da0", "device_tracker.1921687172_544f03bf4da0"]}, "service_call_id": "5fe12f596159453b8527d1b8ab7a46c1"}', 'LOCAL', datetime.datetime(2018, 12, 11, 20, 57, 16, 905916, tzinfo=<UTC>), datetime.datetime(2018, 12, 11, 20, 58, 13, 195335), '0264b3880188460386d6c7391d96663d', None)] (Background on this error at: http://sqlalche.me/e/9h9h)

Woopsie :crazy_face: waaaay to many bluetooth devices pass by and no way of disabling adding new to known devices so turned this off until some more options are available to stop it from filling up the known devices.

Did you try setting the rssi_threshold to exclude devices that are rather far away? At least if you do room-presence you don’t really need to include all devices passing down the street.

I may try that but windows are facing a street that has a lot of traffic pretty close so it may pick up more than i want anyway so it would be better to have an option to disable auto adding to known devices when I have those I want.

2 Likes

I think you can do that via device tracker config:

- platform: googlehome
  new_device_defaults:
      track_new_devices: false
      hide_if_away: true

Edit: Okay my bad, they will still be added in known_devices.yaml. Sorry.

Note that setting track_new_devices:false will still result in new devices being recorded in known_devices.yaml , but they won’t be tracked ( track: no ).

Sounds like I might run into this same issue as my setup is very similar. Any chance you can post the steps you took our what table you had to drop to get things back up and running in case I run into the same thing.

I just dropped all tables an lost all history, suggest you turn it off and clean up knwon_devices instead until it’s fixed (my opinion).

I set up Owntracks again instead with the new 0.84.1 update with webhooks it’s really easy (had it set up with the old rpi3 and certificates and complex-ish setup and opened ports for mqtt) with the nabu casa webhooks it’s so simple https://www.nabucasa.com/config/webhooks/

No I’m not affiliated but I want to contribute to the cause/new employees, paying a little bit sure makes me feel good when I had so much use of home-assistant since I got it for free and kudos to all developers, volunteers and also ubiquiti who help the project. :sparkling_heart:

Room tracking is not really applicable because small appartement and home-made PIR sensors take care of lights and alarms, just need a reliable/quick precence, wifi with unifi precence is slow if going inside to quick and alarms go off/cameras not disabled so did a group with both unifi and Owntracks for now.

OK so I have this working fairly well now

1a) Changed all non required known Devices to track: false
1b) Set google home components to track_new_devices: false
1c) Set each google home up to scan every 8 seconds (to not crash anything) will try my luck dropping this value and see if their is any impact
1d) Set each google home rssi_threshold to -100 (so they are reporting rssi with my phone anywhere in the house)

consider_home not required in this setup, will comment out

device_tracker:
# Bedroom Speaker
  - platform: googlehome
    host: 192.168.86.249    
    rssi_threshold: -100
    interval_seconds: 8
    consider_home: 20
    new_device_defaults:
      track_new_devices: false

# Kitchen Speaker 
  - platform: googlehome
    host: 192.168.86.250
    interval_seconds: 8
    consider_home: 20    
    rssi_threshold: -100
    new_device_defaults:
      track_new_devices: false

# Main Room Speaker   
  - platform: googlehome
    host: 192.168.86.35
    rssi_threshold: -100
    interval_seconds: 8
    consider_home: 30
    new_device_defaults:
      track_new_devices: false
      
# Kitchen Display    
  - platform: googlehome
    host: 192.168.86.24
    rssi_threshold: -100 
    interval_seconds: 8
    consider_home: 24
    new_device_defaults:
      track_new_devices: false
      
# Outside Speaker     
#  - platform: googlehome
#    host: 192.168.86.29
#    rssi_threshold: -100
#    interval_seconds: 1
#    consider_home: 5
#    new_device_defaults:
#      track_new_devices: false
         
# Lounge Room Speaker     
  - platform: googlehome
    host: 192.168.86.63
    rssi_threshold: -100   
    interval_seconds: 8
    consider_home: 24
    new_device_defaults:
      track_new_devices: false
  1. Created template sensors to report rssi values

sensor:
  - platform: template   
    sensors:
      bedroom_op6t_rssi:
        value_template: '{{ states.device_tracker.bedroom_op6t_tracking.attributes.rssi }}'
        
  - platform: template   
    sensors:
      hallway_op6t_rssi:
        value_template: '{{ states.device_tracker.hallway_op6t_tracking.attributes.rssi }}'
        
  - platform: template   
    sensors:
      kitchen_display_op6t_rssi:
        value_template: '{{ states.device_tracker.kitchen_display_op6t_tracking.attributes.rssi }}'
        
  - platform: template   
    sensors:
      kitchen_op6t_rssi:
        value_template: '{{ states.device_tracker.kitchen_op6t_tracking.attributes.rssi }}'
        
  - platform: template   
    sensors:
      lounge_op6t_rssi:
        value_template: '{{ states.device_tracker.lounge_op6t_tracking.attributes.rssi }}'
        
  - platform: template   
    sensors:
      mainroon_op6t_rssi:
        value_template: '{{ states.device_tracker.mainroom_op6t_tracking.attributes.rssi }}'    
        
  1. Created Input_select dropdown list for each room in the house with google home
input_select:
  dan_room_location:
    name: Dan's Room Location
    options:
      - Main Room
      - Kitchen
      - Lounge Room
      - Bedroom
  1. Created Automations to choose correct room from dropdown list based on what rooms google home has the lowest rssi value compared to others
automation:
- id: In Main Room
  alias: In Main Room
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: sensor.mainroon_op6t_rssi
  condition:
    condition: and
    conditions:
#    - condition: template
#      value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.kitchen_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.kitchen_display_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"      
#    - condition: template
#      value_template: "{{ ( states.sensor.hallway_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
  action:
    - service: input_select.select_option
      data:
        entity_id: input_select.dan_room_location
        option: Main Room      
     
- id: In Kitchen
  alias: In Kitchen
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: sensor.kitchen_display_op6t_rssi
  - platform: time
    seconds: '/10'    
  condition:
    condition: and
    conditions:
    - condition: template
      value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state  )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.mainroon_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state )  }}"
#    - condition: template
#      value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state )  }}"      
#    - condition: template
#      value_template: "{{ ( states.sensor.hallway_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state  )  }}"  
  action:
    - service: input_select.select_option
      data:
        entity_id: input_select.dan_room_location
        option: Kitchen  
        
- id: In Bedroom
  alias: In Bedroom
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: sensor.bedroom_op6t_rssi
  condition:
    condition: and
    conditions:
#    - condition: template
#      value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state  )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.mainroon_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state )  }}"
#    - condition: template
#      value_template: "{{ ( states.sensor.kitchen_display_op6t_rssi.state ) > (states.sensor.bedroom_op6t_rssi.state )  }}"      
#    - condition: template
#      value_template: "{{ ( states.sensor.hallway_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state )  }}"  
  action:
    - service: input_select.select_option
      data:
        entity_id: input_select.dan_room_location
        option: Bedroom        

- id: In Lounge Room
  alias: In Lounge Room
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: sensor.lounge_op6t_rssi
  condition:
    condition: and
    conditions:
#    - condition: template
#      value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.lounge_op6t_rssi.state  )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.mainroon_op6t_rssi.state ) > ( states.sensor.lounge_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.lounge_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.kitchen_op6t_rssi.state ) > ( states.sensor.lounge_op6t_rssi.state )  }}"      
#    - condition: template
#      value_template: "{{ ( states.sensor.hallway_op6t_rssi.state ) > ( states.sensor.lounge_op6t_rssi.state )  }}"  
  action:
    - service: input_select.select_option
      data:
        entity_id: input_select.dan_room_location
        option: Lounge Room
  1. Created a Template Sensor to report room im in
  - platform: template
    sensors:
      dan_room_status:
        value_template: '{{ states.input_select.dan_room_location.state }}'
        friendly_name: 'Dans in the' 

Well that was my Saturday.

If anyone knows how I can change this config so that the reported room will not change momentarily as the rssi value increases in another room for a brief moment. please let me know?

There is probably a more elegant way to do this, but it works (so far)

Now to use it for other automations!

10 Likes

That looks brilliant! If it works maybe room level tracking could be included in the location sensor more seemlessly using this logic.

For reducing the random changes could you use another automation to update a new variable say dan_room_location_stable only when dan_room_location has been the same for long enough to exclude those random events? Sorry I can’t help with actual syntax I have something similar for my finder room tracking but I’m on mobile and am nowhere near good enough to remember it off by heart :).

Good luck!

Thanks Man! It does work and so far so good.

I have tweaked the automation to create a delay before taking action with the change. So after say 10 seconds check the conditions are still met, then change the room. It has made a difference but I think I may need to increase the delay to make it more solid. Although doing so means that there is a larger delay in picking up a change in room. Which limits some automation abilities. Want to try and find a good balance between the two.

Although, I think this could be elevated by how all the other automation are written that use the state. something like you are suggesting, thats for another day! haha!

here is the updated automation


- id: In Main Room
  alias: In Main Room
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: sensor.mainroon_op6t_rssi
  condition:
    condition: and
    conditions:
#    - condition: template
#      value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.kitchen_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.kitchen_display_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"      
#    - condition: template
#      value_template: "{{ ( states.sensor.hallway_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
  action:
    - delay: 00:00:10  
    - condition: and
      conditions:
#      - condition: template
#        value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
      - condition: template
        value_template: "{{ ( states.sensor.kitchen_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
      - condition: template
        value_template: "{{ ( states.sensor.kitchen_display_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"
      - condition: template
        value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"      
#      - condition: template
#        value_template: "{{ ( states.sensor.hallway_op6t_rssi.state ) > ( states.sensor.mainroon_op6t_rssi.state )  }}"    
    - service: input_select.select_option
      data:
        entity_id: input_select.dan_room_location
        option: Main Room      
     
- id: In Kitchen
  alias: In Kitchen
  initial_state: 'on'
  trigger:
  - platform: state
    entity_id: sensor.kitchen_display_op6t_rssi  
  condition:
    condition: and
    conditions:
    - condition: template
      value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state  )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.mainroon_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state )  }}"
#    - condition: template
#      value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state )  }}"      
#    - condition: template
#      value_template: "{{ ( states.sensor.hallway_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state  )  }}"  
  action:
    - delay: 00:00:10
    - condition: and
      conditions:
      - condition: template
        value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state  )  }}"
      - condition: template
        value_template: "{{ ( states.sensor.mainroon_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state )  }}"
      - condition: template
        value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.kitchen_display_op6t_rssi.state )  }}"
    - service: input_select.select_option
      data:
        entity_id: input_select.dan_room_location
        option: Kitchen  
        
- id: In Bedroom
  alias: In Bedroom
  initial_state: 'on'
  trigger:
    platform: state
    entity_id: sensor.bedroom_op6t_rssi
  condition:
    condition: and
    conditions:
#    - condition: template
#      value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state  )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.mainroon_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state )  }}"
    - condition: template
      value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state )  }}"
#    - condition: template
#      value_template: "{{ ( states.sensor.kitchen_display_op6t_rssi.state ) > (states.sensor.bedroom_op6t_rssi.state )  }}"      
#    - condition: template
#      value_template: "{{ ( states.sensor.hallway_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state )  }}"  
  action:
    - delay: 00:00:10
    - condition: and
      conditions:
#      - condition: template
#        value_template: "{{ ( states.sensor.bedroom_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state  )  }}"
      - condition: template
        value_template: "{{ ( states.sensor.mainroon_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state )  }}"
      - condition: template
        value_template: "{{ ( states.sensor.lounge_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state )  }}"
#      - condition: template
#        value_template: "{{ ( states.sensor.kitchen_display_op6t_rssi.state ) > (states.sensor.bedroom_op6t_rssi.state )  }}"      
#      - condition: template
#        value_template: "{{ ( states.sensor.hallway_op6t_rssi.state ) > ( states.sensor.bedroom_op6t_rssi.state )  }}"      
    - service: input_select.select_option
      data:
        entity_id: input_select.dan_room_location
        option: Bedroom  

Still hasnt fixed the issue - there seems to be quite a fluctuation in signal strength from all devices, interference perhaps?

Nice :). Yeah the delay is annoying but it’s better than anything else I’ve found, finder is close to a minute delay on a good day. It’s still really useful for some automations though. I use it to turn off lights in empty rooms or keep them on if I’m in a room. I still need a motion sensor to turn on the light instantly(ish) when I first walk in.

Yeah PIR’s are my go to also. Although I want to test out some Microwave sensors, but at least with the google home setup I will no longer have the light turn off on me while Im sitting at the Kitchen bench reading!

Botts, off-topic, but I have tested a number of microwave sensors (ESP8266-based) and they are too sensitive (even with the sensitivity turned down, resistors and capacitors added) to be really effective. Let me know if you get any to work…

I feel like this component will be awesome when the kinks are worked out. The worst thing about it is that it requires static IPs for the Google homes. Surely it could piggyback off of the cast component somehow to figure that out and you could just reference the media_player entity in the config.

Anybody uses mi band 2?
It has discoverable mode, but I face some problems.
As soon as phone connects to mi band, mi band becomes invisible.

The same things happens with my amazfit watch.

I have just setup my Fitbit Flex 2 to work the same as my phone does. But as it only polls every 2 minutes it takes a bit longer to register as in room X

I have a Mi Band 2, If I find it (missing in the house) ill try this also and let you know if I have any luck!

Microwave sensor as presence detection?

Klagio, yes. Actually as motion detection.