I’m getting no update, just after restarting Hassio.
I’m running on 0.69.1 (was the same with 0.69) on RPi 3 B
I get these error messages in the log
2018-05-13 14:24:50 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform google_maps
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/__init__.py", line 184, in async_setup_platform
disc_info)
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 36, in setup_scanner
scanner = GoogleMapsScanner(hass, config, see)
File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 55, in __init__
self._update_info()
File "/usr/lib/python3.6/site-packages/homeassistant/components/device_tracker/google_maps.py", line 68, in _update_info
dev_id = 'google_maps_{0}'.format(slugify(person.id))
File "/usr/lib/python3.6/site-packages/homeassistant/util/__init__.py", line 43, in slugify
text = normalize('NFKD', text)
TypeError: normalize() argument 2 must be str, not None
Maybe I’m saying too obvious things, but have you tried deleting the .google_maps_location_sharing.cookies file and restarting the Home Assistant? This file is hidden and located in the folder config
Yes, I’ve tried several times to remove the .google_maps_location_sharing.cookies file in the config folder.
When I do, I get the security alert mail from google and it does update just after restarting Hass.io. Then no more updates.
If I just restart Hass.io, I get an update (no security mail) and then no more.
@costas I use this component for several days. It works fine, but sometimes the location is read with rather low accuracy (up to 3128 meters). I read in this thread that the component previously allowed to set the accuracy threshold, but now I see only two variables in the component description: username and password.
Is there any way to filter the location with an accuracy of more than 150 meters?
It seems like the person.id is blank when it is the location of the account that is being used that is sent back. I changed line 68 of “google_maps.py” to read:
dev_id = ‘google_maps_{0}’.format(slugify(person.id if person.id is not None else ‘Patrick’))
@Yevgeniy I am actually on an old HA version so still using a custom component, which indeed has a fix for accuracy. Don’t really remember where I got it exactly from but here it is…
"""
Support for Google Maps location sharing.
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/device_tracker.google_maps/
"""
import logging
from datetime import timedelta
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (
PLATFORM_SCHEMA, SOURCE_TYPE_GPS)
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
from homeassistant.helpers.event import track_time_interval
from homeassistant.helpers.typing import ConfigType
from homeassistant.util import slugify
_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['locationsharinglib==1.2.1']
CONF_MAX_GPS_ACCURACY = 'max_gps_accuracy'
CREDENTIALS_FILE = '.google_maps_location_sharing.cookies'
MIN_TIME_BETWEEN_SCANS = timedelta(seconds=30)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
vol.Optional(CONF_MAX_GPS_ACCURACY): vol.Coerce(float),
})
def setup_scanner(hass, config: ConfigType, see, discovery_info=None):
"""Set up the scanner."""
scanner = GoogleMapsScanner(hass, config, see)
return scanner.success_init
class GoogleMapsScanner(object):
"""Representation of an Google Maps location sharing account."""
def __init__(self, hass, config: ConfigType, see) -> None:
"""Initialize the scanner."""
from locationsharinglib import Service
from locationsharinglib.locationsharinglibexceptions import InvalidUser
self.see = see
self.username = config[CONF_USERNAME]
self.password = config[CONF_PASSWORD]
self.max_gps_accuracy = config[CONF_MAX_GPS_ACCURACY]
try:
self.service = Service(self.username, self.password,
hass.config.path(CREDENTIALS_FILE))
self._update_info()
track_time_interval(
hass, self._update_info, MIN_TIME_BETWEEN_SCANS)
self.success_init = True
except InvalidUser:
_LOGGER.error('You have specified invalid login credentials')
self.success_init = False
def _update_info(self, now=None):
for person in self.service.get_all_people():
dev_id = 'google_maps_{0}'.format(slugify(person.id))
if self.max_gps_accuracy is not None and \
person.accuracy > self.max_gps_accuracy:
_LOGGER.info("Ignoring update because expected GPS "
"accuracy %s is not met: %s",
self.max_gps_accuracy, person.accuracy)
continue
attrs = {
'id': person.id,
'nickname': person.nickname,
'full_name': person.full_name,
'last_seen': person.datetime,
'address': person.address
}
self.see(
dev_id=dev_id,
gps=(person.latitude, person.longitude),
picture=person.picture_url,
source_type=SOURCE_TYPE_GPS,
attributes=attrs
)
Please update the version of the underlying library to the latest version.
For everyone having issues with random lock outs from google please use the latest version and report on the issue tracker of the library until we get all of the issues fixed.