parent
909f2448ca
commit
cc5edf69e3
1 changed files with 19 additions and 11 deletions
|
@ -12,14 +12,18 @@ import voluptuous as vol
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.components.device_tracker import (
|
from homeassistant.components.device_tracker import (
|
||||||
PLATFORM_SCHEMA, SOURCE_TYPE_GPS)
|
PLATFORM_SCHEMA, SOURCE_TYPE_GPS)
|
||||||
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD
|
from homeassistant.const import CONF_USERNAME, CONF_PASSWORD, ATTR_ID
|
||||||
from homeassistant.helpers.event import track_time_interval
|
from homeassistant.helpers.event import track_time_interval
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.util import slugify
|
|
||||||
|
REQUIREMENTS = ['locationsharinglib==2.0.2']
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
REQUIREMENTS = ['locationsharinglib==2.0.2']
|
ATTR_ADDRESS = 'address'
|
||||||
|
ATTR_FULL_NAME = 'full_name'
|
||||||
|
ATTR_LAST_SEEN = 'last_seen'
|
||||||
|
ATTR_NICKNAME = 'nickname'
|
||||||
|
|
||||||
CREDENTIALS_FILE = '.google_maps_location_sharing.cookies'
|
CREDENTIALS_FILE = '.google_maps_location_sharing.cookies'
|
||||||
|
|
||||||
|
@ -60,19 +64,23 @@ class GoogleMapsScanner(object):
|
||||||
self.success_init = True
|
self.success_init = True
|
||||||
|
|
||||||
except InvalidUser:
|
except InvalidUser:
|
||||||
_LOGGER.error('You have specified invalid login credentials')
|
_LOGGER.error("You have specified invalid login credentials")
|
||||||
self.success_init = False
|
self.success_init = False
|
||||||
|
|
||||||
def _update_info(self, now=None):
|
def _update_info(self, now=None):
|
||||||
for person in self.service.get_all_people():
|
for person in self.service.get_all_people():
|
||||||
dev_id = 'google_maps_{0}'.format(slugify(person.id))
|
try:
|
||||||
|
dev_id = 'google_maps_{0}'.format(person.id)
|
||||||
|
except TypeError:
|
||||||
|
_LOGGER.warning("No location(s) shared with this account")
|
||||||
|
return
|
||||||
|
|
||||||
attrs = {
|
attrs = {
|
||||||
'id': person.id,
|
ATTR_ADDRESS: person.address,
|
||||||
'nickname': person.nickname,
|
ATTR_FULL_NAME: person.full_name,
|
||||||
'full_name': person.full_name,
|
ATTR_ID: person.id,
|
||||||
'last_seen': person.datetime,
|
ATTR_LAST_SEEN: person.datetime,
|
||||||
'address': person.address
|
ATTR_NICKNAME: person.nickname,
|
||||||
}
|
}
|
||||||
self.see(
|
self.see(
|
||||||
dev_id=dev_id,
|
dev_id=dev_id,
|
||||||
|
@ -80,5 +88,5 @@ class GoogleMapsScanner(object):
|
||||||
picture=person.picture_url,
|
picture=person.picture_url,
|
||||||
source_type=SOURCE_TYPE_GPS,
|
source_type=SOURCE_TYPE_GPS,
|
||||||
gps_accuracy=person.accuracy,
|
gps_accuracy=person.accuracy,
|
||||||
attributes=attrs
|
attributes=attrs,
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue