Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
229d19bb
Unverified
Commit
229d19bb
authored
6 years ago
by
Paulus Schoutsen
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix lint (#21520)
parent
548d7bbe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
homeassistant/components/person/__init__.py
+12
-9
12 additions, 9 deletions
homeassistant/components/person/__init__.py
homeassistant/components/sensor/airvisual.py
+2
-2
2 additions, 2 deletions
homeassistant/components/sensor/airvisual.py
with
14 additions
and
11 deletions
homeassistant/components/person/__init__.py
+
12
−
9
View file @
229d19bb
...
...
@@ -2,6 +2,7 @@
from
collections
import
OrderedDict
from
itertools
import
chain
import
logging
from
typing
import
Optional
import
uuid
import
voluptuous
as
vol
...
...
@@ -13,7 +14,7 @@ from homeassistant.const import (
ATTR_ID
,
ATTR_LATITUDE
,
ATTR_LONGITUDE
,
ATTR_GPS_ACCURACY
,
CONF_ID
,
CONF_NAME
,
EVENT_HOMEASSISTANT_START
,
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
import
homeassistant.helpers.config_validation
as
cv
from
homeassistant.helpers.entity_component
import
EntityComponent
...
...
@@ -377,11 +378,6 @@ class Person(RestoreEntity):
"""
Handle the device tracker state changes.
"""
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
def
_update_state
(
self
):
"""
Update the state.
"""
...
...
@@ -393,11 +389,11 @@ class Person(RestoreEntity):
continue
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
:
latest_home
=
self
.
_get_latest
(
latest_home
,
state
)
latest_home
=
_get_latest
(
latest_home
,
state
)
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
:
latest
=
latest_home
...
...
@@ -508,3 +504,10 @@ async def ws_delete_person(hass: HomeAssistantType,
manager
=
hass
.
data
[
DOMAIN
]
# type: PersonManager
await
manager
.
async_delete_person
(
msg
[
'
person_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
This diff is collapsed.
Click to expand it.
homeassistant/components/sensor/airvisual.py
+
2
−
2
View file @
229d19bb
...
...
@@ -141,7 +141,7 @@ async def async_setup_platform(
"
Using city, state, and country: %s, %s, %s
"
,
city
,
state
,
country
)
location_id
=
'
,
'
.
join
((
city
,
state
,
country
))
data
=
AirVisualData
(
Client
(
config
[
CONF_API_KEY
]
,
websession
),
Client
(
websession
,
api_key
=
config
[
CONF_API_KEY
]),
city
=
city
,
state
=
state
,
country
=
country
,
...
...
@@ -152,7 +152,7 @@ async def async_setup_platform(
"
Using latitude and longitude: %s, %s
"
,
latitude
,
longitude
)
location_id
=
'
,
'
.
join
((
str
(
latitude
),
str
(
longitude
)))
data
=
AirVisualData
(
Client
(
config
[
CONF_API_KEY
]
,
websession
),
Client
(
websession
,
api_key
=
config
[
CONF_API_KEY
]),
latitude
=
latitude
,
longitude
=
longitude
,
show_on_map
=
config
[
CONF_SHOW_ON_MAP
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment