Adds support for disabled Tiles and automatic session renewal (#11172)
* Adds support for disabled Tiles and automatic session renewal * Updated requirements * Collaborator-requested changes * Collaborator-requested changes
This commit is contained in:
parent
8c303bf48c
commit
5566ea8c81
2 changed files with 19 additions and 21 deletions
|
@ -19,7 +19,7 @@ from homeassistant.util.json import load_json, save_json
|
|||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
REQUIREMENTS = ['pytile==1.0.0']
|
||||
REQUIREMENTS = ['pytile==1.1.0']
|
||||
|
||||
CLIENT_UUID_CONFIG_FILE = '.tile.conf'
|
||||
DEFAULT_ICON = 'mdi:bluetooth'
|
||||
|
@ -29,14 +29,15 @@ ATTR_ALTITUDE = 'altitude'
|
|||
ATTR_CONNECTION_STATE = 'connection_state'
|
||||
ATTR_IS_DEAD = 'is_dead'
|
||||
ATTR_IS_LOST = 'is_lost'
|
||||
ATTR_LAST_SEEN = 'last_seen'
|
||||
ATTR_LAST_UPDATED = 'last_updated'
|
||||
ATTR_RING_STATE = 'ring_state'
|
||||
ATTR_VOIP_STATE = 'voip_state'
|
||||
|
||||
CONF_SHOW_INACTIVE = 'show_inactive'
|
||||
|
||||
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||
vol.Required(CONF_USERNAME): cv.string,
|
||||
vol.Required(CONF_PASSWORD): cv.string,
|
||||
vol.Optional(CONF_SHOW_INACTIVE, default=False): cv.boolean,
|
||||
vol.Optional(CONF_MONITORED_VARIABLES):
|
||||
vol.All(cv.ensure_list, [vol.In(DEVICE_TYPES)]),
|
||||
})
|
||||
|
@ -79,6 +80,7 @@ class TileDeviceScanner(DeviceScanner):
|
|||
_LOGGER.debug('Client UUID: %s', self._client.client_uuid)
|
||||
_LOGGER.debug('User UUID: %s', self._client.user_uuid)
|
||||
|
||||
self._show_inactive = config.get(CONF_SHOW_INACTIVE)
|
||||
self._types = config.get(CONF_MONITORED_VARIABLES)
|
||||
|
||||
self.devices = {}
|
||||
|
@ -91,29 +93,25 @@ class TileDeviceScanner(DeviceScanner):
|
|||
|
||||
def _update_info(self, now=None) -> None:
|
||||
"""Update the device info."""
|
||||
device_data = self._client.get_tiles(type_whitelist=self._types)
|
||||
self.devices = self._client.get_tiles(
|
||||
type_whitelist=self._types, show_inactive=self._show_inactive)
|
||||
|
||||
try:
|
||||
self.devices = device_data['result']
|
||||
except KeyError:
|
||||
if not self.devices:
|
||||
_LOGGER.warning('No Tiles found')
|
||||
_LOGGER.debug(device_data)
|
||||
return
|
||||
|
||||
for info in self.devices.values():
|
||||
dev_id = 'tile_{0}'.format(slugify(info['name']))
|
||||
lat = info['tileState']['latitude']
|
||||
lon = info['tileState']['longitude']
|
||||
for dev in self.devices:
|
||||
dev_id = 'tile_{0}'.format(slugify(dev['name']))
|
||||
lat = dev['tileState']['latitude']
|
||||
lon = dev['tileState']['longitude']
|
||||
|
||||
attrs = {
|
||||
ATTR_ALTITUDE: info['tileState']['altitude'],
|
||||
ATTR_CONNECTION_STATE: info['tileState']['connection_state'],
|
||||
ATTR_IS_DEAD: info['is_dead'],
|
||||
ATTR_IS_LOST: info['tileState']['is_lost'],
|
||||
ATTR_LAST_SEEN: info['tileState']['timestamp'],
|
||||
ATTR_LAST_UPDATED: device_data['timestamp_ms'],
|
||||
ATTR_RING_STATE: info['tileState']['ring_state'],
|
||||
ATTR_VOIP_STATE: info['tileState']['voip_state'],
|
||||
ATTR_ALTITUDE: dev['tileState']['altitude'],
|
||||
ATTR_CONNECTION_STATE: dev['tileState']['connection_state'],
|
||||
ATTR_IS_DEAD: dev['is_dead'],
|
||||
ATTR_IS_LOST: dev['tileState']['is_lost'],
|
||||
ATTR_RING_STATE: dev['tileState']['ring_state'],
|
||||
ATTR_VOIP_STATE: dev['tileState']['voip_state'],
|
||||
}
|
||||
|
||||
self.see(
|
||||
|
|
|
@ -928,7 +928,7 @@ pythonegardia==1.0.22
|
|||
pythonwhois==2.4.3
|
||||
|
||||
# homeassistant.components.device_tracker.tile
|
||||
pytile==1.0.0
|
||||
pytile==1.1.0
|
||||
|
||||
# homeassistant.components.device_tracker.trackr
|
||||
pytrackr==0.0.5
|
||||
|
|
Loading…
Add table
Reference in a new issue