diff --git a/custom_components/openwrt/sensor.py b/custom_components/openwrt/sensor.py index a410c56..f14fc7e 100644 --- a/custom_components/openwrt/sensor.py +++ b/custom_components/openwrt/sensor.py @@ -4,7 +4,7 @@ from homeassistant.components.sensor import SensorEntity from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import EntityCategory - +from homeassistant.components.sensor import SensorDeviceClass import logging @@ -243,7 +243,8 @@ def __init__(self, device, device_id: str, interface: str, code: str): self._code = code self._attr_entity_category = EntityCategory.DIAGNOSTIC self._attr_icon = "mdi:download-network" if code == "rx" else "mdi:upload-network" - self._attr_native_unit_of_measurement = "bytes" + self._attr_device_class = SensorDeviceClass.DATA_SIZE + self._attr_native_unit_of_measurement = "B" @property def _data(self): @@ -267,7 +268,7 @@ def native_value(self): @property def extra_state_attributes(self): - return dict(mac=self._data.get("macaddr"), speed=self._data.get("speed")) + return dict(mac=self._data.get("mac"), speed=self._data.get("speed")) @property def state_class(self):