Skip to content

Commit

Permalink
feat: Add additional sensors
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed May 2, 2021
1 parent b65f29f commit af44666
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
43 changes: 42 additions & 1 deletion custom_components/weenect/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_SIGNAL_STRENGTH,
DEVICE_CLASS_TIMESTAMP,
PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS,
)

# Base component constants
Expand All @@ -27,32 +29,71 @@
"value_name": "battery",
"device_class": DEVICE_CLASS_BATTERY,
"enabled": True,
"unit_of_measurement": PERCENTAGE,
},
{
"name": "Cell Tower Id",
"value_name": "cellid",
"device_class": None,
"enabled": True,
"unit_of_measurement": None,
},
{
"name": "GSM Strength",
"value_name": "gsm",
"device_class": DEVICE_CLASS_SIGNAL_STRENGTH,
"enabled": True,
"unit_of_measurement": SIGNAL_STRENGTH_DECIBELS,
},
{
"name": "Last Message Received",
"value_name": "last_message",
"device_class": DEVICE_CLASS_TIMESTAMP,
"enabled": True,
"unit_of_measurement": "ISO8601",
},
{
"name": "GPS Satellites",
"value_name": "satellites",
"device_class": None,
"enabled": True,
"unit_of_measurement": None,
},
{
"name": "Update Rate",
"value_name": "freq_mode",
"device_class": None,
"enabled": True,
"unit_of_measurement": None,
},
{
"name": "Last Update Rate",
"value_name": "last_freq_mode",
"device_class": None,
"enabled": True,
"unit_of_measurement": None,
},
{
"name": "Sensor Mode",
"value_name": "sensor_mode",
"device_class": None,
"enabled": True,
"unit_of_measurement": None,
},
{
"name": "Last Sensor Mode",
"value_name": "last_sensor_mode",
"device_class": None,
"enabled": True,
"unit_of_measurement": None,
},
{
"name": "Type",
"value_name": "type",
"device_class": None,
"enabled": False,
"unit_of_measurement": None,
},
{"name": "Type", "value_name": "type", "device_class": None, "enabled": False},
]

BINARY_SENSOR_TYPES = [
Expand Down
6 changes: 6 additions & 0 deletions custom_components/weenect/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def __init__(
self._value_name = sensor_type["value_name"]
self._enabled = sensor_type["enabled"]
self._name = sensor_type["name"]
self._unit_of_measurement = sensor_type["unit_of_measurement"]

@property
def name(self):
Expand Down Expand Up @@ -81,3 +82,8 @@ def device_class(self):
def entity_registry_enabled_default(self) -> bool:
"""Return if the entity should be enabled when first added to the entity registry."""
return self._enabled

@property
def unit_of_measurement(self):
"""Return the units of measurement."""
return self._unit_of_measurement

0 comments on commit af44666

Please sign in to comment.