Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Add netgear_lte connection sensors (home-assistant#22558)
Browse files Browse the repository at this point in the history
  • Loading branch information
amelchio authored and unknown committed Apr 7, 2019
1 parent ca8b6f5 commit d110e70
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/netgear_lte/__init__.py
Expand Up @@ -20,7 +20,7 @@

from . import sensor_types

REQUIREMENTS = ['eternalegypt==0.0.5']
REQUIREMENTS = ['eternalegypt==0.0.6']

_LOGGER = logging.getLogger(__name__)

Expand Down
11 changes: 11 additions & 0 deletions homeassistant/components/netgear_lte/sensor.py
Expand Up @@ -36,6 +36,8 @@ async def async_setup_platform(
sensors.append(SMSSensor(modem_data, sensor_type))
elif sensor_type == SENSOR_USAGE:
sensors.append(UsageSensor(modem_data, sensor_type))
else:
sensors.append(GenericSensor(modem_data, sensor_type))

async_add_entities(sensors)

Expand Down Expand Up @@ -106,3 +108,12 @@ class UsageSensor(LTESensor):
def state(self):
"""Return the state of the sensor."""
return round(self.modem_data.data.usage / 1024**2, 1)


class GenericSensor(LTESensor):
"""Sensor entity with raw state."""

@property
def state(self):
"""Return the state of the sensor."""
return getattr(self.modem_data.data, self.sensor_type)
13 changes: 13 additions & 0 deletions homeassistant/components/netgear_lte/sensor_types.py
Expand Up @@ -6,6 +6,19 @@
SENSOR_UNITS = {
SENSOR_SMS: 'unread',
SENSOR_USAGE: 'MiB',
'radio_quality': '%',
'rx_level': 'dBm',
'tx_level': 'dBm',
'upstream': None,
'wire_connected': None,
'mobile_connected': None,
'connection_text': None,
'connection_type': None,
'current_ps_service_type': None,
'register_network_display': None,
'roaming': None,
'current_band': None,
'cell_id': None,
}

ALL = list(SENSOR_UNITS)
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Expand Up @@ -407,7 +407,7 @@ ephem==3.7.6.0
epson-projector==0.1.3

# homeassistant.components.netgear_lte
eternalegypt==0.0.5
eternalegypt==0.0.6

# homeassistant.components.keyboard_remote
# evdev==0.6.1
Expand Down

0 comments on commit d110e70

Please sign in to comment.