Update Google Maps Location Tracker to use locationsharinglib==4.0.2 (#25316)
* Update google_maps: Bump locationsharinglib to 4.0.2 * Remove unused import. * Corrections based on review.pull/25362/head
parent
fc5b1c7005
commit
83581be4d5
|
@ -2,17 +2,19 @@
|
|||
from datetime import timedelta
|
||||
import logging
|
||||
|
||||
from locationsharinglib import Service
|
||||
from locationsharinglib.locationsharinglibexceptions import InvalidCookies
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.device_tracker import (
|
||||
PLATFORM_SCHEMA, SOURCE_TYPE_GPS)
|
||||
from homeassistant.const import (
|
||||
ATTR_ID, CONF_PASSWORD, CONF_USERNAME, ATTR_BATTERY_CHARGING,
|
||||
ATTR_BATTERY_LEVEL)
|
||||
ATTR_BATTERY_CHARGING, ATTR_BATTERY_LEVEL, ATTR_ID, CONF_SCAN_INTERVAL,
|
||||
CONF_USERNAME)
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.event import track_time_interval
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.util import slugify, dt as dt_util
|
||||
from homeassistant.util import dt as dt_util, slugify
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
@ -25,10 +27,7 @@ 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_PASSWORD): cv.string,
|
||||
vol.Required(CONF_USERNAME): cv.string,
|
||||
vol.Optional(CONF_MAX_GPS_ACCURACY, default=100000): vol.Coerce(float),
|
||||
})
|
||||
|
@ -45,27 +44,27 @@ class GoogleMapsScanner:
|
|||
|
||||
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]
|
||||
self.scan_interval = \
|
||||
timedelta(seconds=config.get(CONF_SCAN_INTERVAL, 60))
|
||||
|
||||
try:
|
||||
credfile = "{}.{}".format(hass.config.path(CREDENTIALS_FILE),
|
||||
slugify(self.username))
|
||||
self.service = Service(self.username, self.password, credfile)
|
||||
try:
|
||||
self.service = Service(credfile, self.username)
|
||||
self._update_info()
|
||||
|
||||
track_time_interval(
|
||||
hass, self._update_info, MIN_TIME_BETWEEN_SCANS)
|
||||
hass, self._update_info, self.scan_interval)
|
||||
|
||||
self.success_init = True
|
||||
|
||||
except InvalidUser:
|
||||
_LOGGER.error("You have specified invalid login credentials")
|
||||
except InvalidCookies:
|
||||
_LOGGER.error("You have specified invalid login credentials. "
|
||||
"Please make sure you have saved your credentials"
|
||||
" in the following file: %s", credfile)
|
||||
self.success_init = False
|
||||
|
||||
def _update_info(self, now=None):
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Google maps",
|
||||
"documentation": "https://www.home-assistant.io/components/google_maps",
|
||||
"requirements": [
|
||||
"locationsharinglib==3.0.11"
|
||||
"locationsharinglib==4.0.2"
|
||||
],
|
||||
"dependencies": [],
|
||||
"codeowners": []
|
||||
|
|
|
@ -733,7 +733,7 @@ liveboxplaytv==2.0.2
|
|||
lmnotify==0.0.4
|
||||
|
||||
# homeassistant.components.google_maps
|
||||
locationsharinglib==3.0.11
|
||||
locationsharinglib==4.0.2
|
||||
|
||||
# homeassistant.components.logi_circle
|
||||
logi_circle==0.2.2
|
||||
|
|
Loading…
Reference in New Issue