Skip to content

Commit

Permalink
Merge pull request #27 from jayanezj/hotfix/correct-rxtx-units
Browse files Browse the repository at this point in the history
Correct RX and TX units
  • Loading branch information
kvj authored Nov 23, 2024
2 parents f4b61b0 + 7b9b7a0 commit 7c1f4c1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions custom_components/openwrt/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit 7c1f4c1

Please sign in to comment.