Skip to content
Snippets Groups Projects
Unverified Commit 229d19bb authored by Paulus Schoutsen's avatar Paulus Schoutsen Committed by GitHub
Browse files

Fix lint (#21520)

parent 548d7bbe
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
from collections import OrderedDict from collections import OrderedDict
from itertools import chain from itertools import chain
import logging import logging
from typing import Optional
import uuid import uuid
import voluptuous as vol import voluptuous as vol
...@@ -13,7 +14,7 @@ from homeassistant.const import ( ...@@ -13,7 +14,7 @@ from homeassistant.const import (
ATTR_ID, ATTR_LATITUDE, ATTR_LONGITUDE, ATTR_GPS_ACCURACY, ATTR_ID, ATTR_LATITUDE, ATTR_LONGITUDE, ATTR_GPS_ACCURACY,
CONF_ID, CONF_NAME, EVENT_HOMEASSISTANT_START, CONF_ID, CONF_NAME, EVENT_HOMEASSISTANT_START,
STATE_UNKNOWN, STATE_UNAVAILABLE, STATE_HOME, STATE_NOT_HOME) STATE_UNKNOWN, STATE_UNAVAILABLE, STATE_HOME, STATE_NOT_HOME)
from homeassistant.core import callback, Event from homeassistant.core import callback, Event, State
from homeassistant.auth import EVENT_USER_REMOVED from homeassistant.auth import EVENT_USER_REMOVED
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_component import EntityComponent from homeassistant.helpers.entity_component import EntityComponent
...@@ -377,11 +378,6 @@ class Person(RestoreEntity): ...@@ -377,11 +378,6 @@ class Person(RestoreEntity):
"""Handle the device tracker state changes.""" """Handle the device tracker state changes."""
self._update_state() self._update_state()
def _get_latest(self, prev, curr):
return curr \
if prev is None or curr.last_updated > prev.last_updated \
else prev
@callback @callback
def _update_state(self): def _update_state(self):
"""Update the state.""" """Update the state."""
...@@ -393,11 +389,11 @@ class Person(RestoreEntity): ...@@ -393,11 +389,11 @@ class Person(RestoreEntity):
continue continue
if state.attributes.get(ATTR_SOURCE_TYPE) == SOURCE_TYPE_GPS: if state.attributes.get(ATTR_SOURCE_TYPE) == SOURCE_TYPE_GPS:
latest_gps = self._get_latest(latest_gps, state) latest_gps = _get_latest(latest_gps, state)
elif state.state == STATE_HOME: elif state.state == STATE_HOME:
latest_home = self._get_latest(latest_home, state) latest_home = _get_latest(latest_home, state)
elif state.state == STATE_NOT_HOME: elif state.state == STATE_NOT_HOME:
latest_not_home = self._get_latest(latest_not_home, state) latest_not_home = _get_latest(latest_not_home, state)
if latest_home: if latest_home:
latest = latest_home latest = latest_home
...@@ -508,3 +504,10 @@ async def ws_delete_person(hass: HomeAssistantType, ...@@ -508,3 +504,10 @@ async def ws_delete_person(hass: HomeAssistantType,
manager = hass.data[DOMAIN] # type: PersonManager manager = hass.data[DOMAIN] # type: PersonManager
await manager.async_delete_person(msg['person_id']) await manager.async_delete_person(msg['person_id'])
connection.send_result(msg['id']) connection.send_result(msg['id'])
def _get_latest(prev: Optional[State], curr: State):
"""Get latest state."""
if prev is None or curr.last_updated > prev.last_updated:
return curr
return prev
...@@ -141,7 +141,7 @@ async def async_setup_platform( ...@@ -141,7 +141,7 @@ async def async_setup_platform(
"Using city, state, and country: %s, %s, %s", city, state, country) "Using city, state, and country: %s, %s, %s", city, state, country)
location_id = ','.join((city, state, country)) location_id = ','.join((city, state, country))
data = AirVisualData( data = AirVisualData(
Client(config[CONF_API_KEY], websession), Client(websession, api_key=config[CONF_API_KEY]),
city=city, city=city,
state=state, state=state,
country=country, country=country,
...@@ -152,7 +152,7 @@ async def async_setup_platform( ...@@ -152,7 +152,7 @@ async def async_setup_platform(
"Using latitude and longitude: %s, %s", latitude, longitude) "Using latitude and longitude: %s, %s", latitude, longitude)
location_id = ','.join((str(latitude), str(longitude))) location_id = ','.join((str(latitude), str(longitude)))
data = AirVisualData( data = AirVisualData(
Client(config[CONF_API_KEY], websession), Client(websession, api_key=config[CONF_API_KEY]),
latitude=latitude, latitude=latitude,
longitude=longitude, longitude=longitude,
show_on_map=config[CONF_SHOW_ON_MAP], show_on_map=config[CONF_SHOW_ON_MAP],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment