Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct RX and TX units #27

Merged
merged 2 commits into from
Nov 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions custom_components/openwrt/sensor.py
Original file line number Diff line number Diff line change
@@ -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):