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
d1b16e28
Commit
d1b16e28
authored
6 years ago
by
Anders Melchiorsen
Committed by
Martin Hjelmare
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add unique_id to netgear_lte sensors (#15584)
parent
ee8a815e
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
homeassistant/components/netgear_lte.py
+3
-1
3 additions, 1 deletion
homeassistant/components/netgear_lte.py
homeassistant/components/sensor/netgear_lte.py
+11
-5
11 additions, 5 deletions
homeassistant/components/sensor/netgear_lte.py
requirements_all.txt
+1
-1
1 addition, 1 deletion
requirements_all.txt
with
15 additions
and
7 deletions
homeassistant/components/netgear_lte.py
+
3
−
1
View file @
d1b16e28
...
...
@@ -17,7 +17,7 @@ from homeassistant.helpers import config_validation as cv
from
homeassistant.helpers.aiohttp_client
import
async_create_clientsession
from
homeassistant.util
import
Throttle
REQUIREMENTS
=
[
'
eternalegypt==0.0.
2
'
]
REQUIREMENTS
=
[
'
eternalegypt==0.0.
3
'
]
MIN_TIME_BETWEEN_UPDATES
=
timedelta
(
seconds
=
10
)
...
...
@@ -37,6 +37,7 @@ class ModemData:
"""
Class for modem state.
"""
modem
=
attr
.
ib
()
serial_number
=
attr
.
ib
(
init
=
False
)
unread_count
=
attr
.
ib
(
init
=
False
)
usage
=
attr
.
ib
(
init
=
False
)
...
...
@@ -44,6 +45,7 @@ class ModemData:
async
def
async_update
(
self
):
"""
Call the API to update the data.
"""
information
=
await
self
.
modem
.
information
()
self
.
serial_number
=
information
.
serial_number
self
.
unread_count
=
sum
(
1
for
x
in
information
.
sms
if
x
.
unread
)
self
.
usage
=
information
.
usage
...
...
This diff is collapsed.
Click to expand it.
homeassistant/components/sensor/netgear_lte.py
+
11
−
5
View file @
d1b16e28
...
...
@@ -32,11 +32,11 @@ async def async_setup_platform(
modem_data
=
hass
.
data
[
DATA_KEY
].
get_modem_data
(
config
)
sensors
=
[]
for
sensortype
in
config
[
CONF_SENSORS
]:
if
sensortype
==
SENSOR_SMS
:
sensors
.
append
(
SMSSensor
(
modem_data
))
elif
sensortype
==
SENSOR_USAGE
:
sensors
.
append
(
UsageSensor
(
modem_data
))
for
sensor
_
type
in
config
[
CONF_SENSORS
]:
if
sensor
_
type
==
SENSOR_SMS
:
sensors
.
append
(
SMSSensor
(
modem_data
,
sensor_type
))
elif
sensor
_
type
==
SENSOR_USAGE
:
sensors
.
append
(
UsageSensor
(
modem_data
,
sensor_type
))
async_add_devices
(
sensors
,
True
)
...
...
@@ -46,11 +46,17 @@ class LTESensor(Entity):
"""
Data usage sensor entity.
"""
modem_data
=
attr
.
ib
()
sensor_type
=
attr
.
ib
()
async
def
async_update
(
self
):
"""
Update state.
"""
await
self
.
modem_data
.
async_update
()
@property
def
unique_id
(
self
):
"""
Return a unique ID like
'
usage_5TG365AB0078V
'
.
"""
return
"
{}_{}
"
.
format
(
self
.
sensor_type
,
self
.
modem_data
.
serial_number
)
class
SMSSensor
(
LTESensor
):
"""
Unread SMS sensor entity.
"""
...
...
This diff is collapsed.
Click to expand it.
requirements_all.txt
+
1
−
1
View file @
d1b16e28
...
...
@@ -309,7 +309,7 @@ ephem==3.7.6.0
epson-projector==0.1.3
# homeassistant.components.netgear_lte
eternalegypt==0.0.
2
eternalegypt==0.0.
3
# homeassistant.components.keyboard_remote
# evdev==0.6.1
...
...
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