diff --git a/custom_components/weenect/const.py b/custom_components/weenect/const.py index c7ddf4e..939386b 100644 --- a/custom_components/weenect/const.py +++ b/custom_components/weenect/const.py @@ -4,6 +4,8 @@ DEVICE_CLASS_BATTERY, DEVICE_CLASS_SIGNAL_STRENGTH, DEVICE_CLASS_TIMESTAMP, + PERCENTAGE, + SIGNAL_STRENGTH_DECIBELS, ) # Base component constants @@ -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 = [ diff --git a/custom_components/weenect/sensor.py b/custom_components/weenect/sensor.py index 8a77034..5f6d02f 100644 --- a/custom_components/weenect/sensor.py +++ b/custom_components/weenect/sensor.py @@ -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): @@ -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