Skip to content

Commit 7c1f4c1

Browse files
authored
Merge pull request #27 from jayanezj/hotfix/correct-rxtx-units
Correct RX and TX units
2 parents f4b61b0 + 7b9b7a0 commit 7c1f4c1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

custom_components/openwrt/sensor.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from homeassistant.components.sensor import SensorEntity
55
from homeassistant.core import HomeAssistant
66
from homeassistant.helpers.entity import EntityCategory
7-
7+
from homeassistant.components.sensor import SensorDeviceClass
88

99
import logging
1010

@@ -243,7 +243,8 @@ def __init__(self, device, device_id: str, interface: str, code: str):
243243
self._code = code
244244
self._attr_entity_category = EntityCategory.DIAGNOSTIC
245245
self._attr_icon = "mdi:download-network" if code == "rx" else "mdi:upload-network"
246-
self._attr_native_unit_of_measurement = "bytes"
246+
self._attr_device_class = SensorDeviceClass.DATA_SIZE
247+
self._attr_native_unit_of_measurement = "B"
247248

248249
@property
249250
def _data(self):
@@ -267,7 +268,7 @@ def native_value(self):
267268

268269
@property
269270
def extra_state_attributes(self):
270-
return dict(mac=self._data.get("macaddr"), speed=self._data.get("speed"))
271+
return dict(mac=self._data.get("mac"), speed=self._data.get("speed"))
271272

272273
@property
273274
def state_class(self):

0 commit comments

Comments
 (0)