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
13006cee
Commit
13006cee
authored
8 years ago
by
Paulus Schoutsen
Committed by
Lewis Juggins
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Device tracker attributes (#4753)
parent
e21382cd
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/device_tracker/__init__.py
+12
-9
12 additions, 9 deletions
homeassistant/components/device_tracker/__init__.py
with
12 additions
and
9 deletions
homeassistant/components/device_tracker/__init__.py
+
12
−
9
View file @
13006cee
...
@@ -332,6 +332,7 @@ class Device(Entity):
...
@@ -332,6 +332,7 @@ class Device(Entity):
gps
=
None
# type: GPSType
gps
=
None
# type: GPSType
gps_accuracy
=
0
gps_accuracy
=
0
last_seen
=
None
# type: dt_util.dt.datetime
last_seen
=
None
# type: dt_util.dt.datetime
battery
=
None
# type: str
attributes
=
None
# type: dict
attributes
=
None
# type: dict
vendor
=
None
# type: str
vendor
=
None
# type: str
...
@@ -369,6 +370,7 @@ class Device(Entity):
...
@@ -369,6 +370,7 @@ class Device(Entity):
self
.
away_hide
=
hide_if_away
self
.
away_hide
=
hide_if_away
self
.
vendor
=
vendor
self
.
vendor
=
vendor
self
.
_attributes
=
{}
@property
@property
def
name
(
self
):
def
name
(
self
):
...
@@ -395,12 +397,16 @@ class Device(Entity):
...
@@ -395,12 +397,16 @@ class Device(Entity):
attr
[
ATTR_LONGITUDE
]
=
self
.
gps
[
1
]
attr
[
ATTR_LONGITUDE
]
=
self
.
gps
[
1
]
attr
[
ATTR_GPS_ACCURACY
]
=
self
.
gps_accuracy
attr
[
ATTR_GPS_ACCURACY
]
=
self
.
gps_accuracy
if
self
.
attributes
:
if
self
.
battery
:
for
key
,
value
in
self
.
attributes
.
items
():
attr
[
ATTR_BATTERY
]
=
self
.
battery
attr
[
key
]
=
value
return
attr
return
attr
@property
def
device_state_attributes
(
self
):
"""
Return device state attributes.
"""
return
self
.
_attributes
@property
@property
def
hidden
(
self
):
def
hidden
(
self
):
"""
If device should be hidden.
"""
"""
If device should be hidden.
"""
...
@@ -415,13 +421,10 @@ class Device(Entity):
...
@@ -415,13 +421,10 @@ class Device(Entity):
self
.
host_name
=
host_name
self
.
host_name
=
host_name
self
.
location_name
=
location_name
self
.
location_name
=
location_name
self
.
gps_accuracy
=
gps_accuracy
or
0
self
.
gps_accuracy
=
gps_accuracy
or
0
if
(
battery
or
attributes
)
and
self
.
attributes
is
None
:
self
.
attributes
=
{}
if
battery
:
self
.
attributes
[
ATTR_BATTERY
]
=
battery
if
attributes
:
if
attributes
:
for
key
,
value
in
attributes
.
items
():
self
.
_attributes
.
update
(
attributes
)
self
.
attributes
[
key
]
=
value
self
.
gps
=
None
self
.
gps
=
None
if
gps
is
not
None
:
if
gps
is
not
None
:
...
...
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