mirror of
https://github.com/home-assistant/core
synced 2024-09-28 03:04:04 +02:00
Use DATA_SIZE device class in netgear lte (#83908)
This commit is contained in:
parent
69bc95a715
commit
1ad4cb40df
@ -1,7 +1,7 @@
|
|||||||
"""Support for Netgear LTE sensors."""
|
"""Support for Netgear LTE sensors."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorEntity
|
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.exceptions import PlatformNotReady
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
@ -73,8 +73,10 @@ class SMSTotalSensor(LTESensor):
|
|||||||
class UsageSensor(LTESensor):
|
class UsageSensor(LTESensor):
|
||||||
"""Data usage sensor entity."""
|
"""Data usage sensor entity."""
|
||||||
|
|
||||||
|
_attr_device_class = SensorDeviceClass.DATA_SIZE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self) -> float:
|
||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return round(self.modem_data.data.usage / 1024**2, 1)
|
return round(self.modem_data.data.usage / 1024**2, 1)
|
||||||
|
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
from homeassistant.components.binary_sensor import BinarySensorDeviceClass
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
DATA_MEBIBYTES,
|
|
||||||
PERCENTAGE,
|
PERCENTAGE,
|
||||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
|
UnitOfInformation,
|
||||||
)
|
)
|
||||||
|
|
||||||
SENSOR_SMS = "sms"
|
SENSOR_SMS = "sms"
|
||||||
@ -14,7 +14,7 @@ SENSOR_USAGE = "usage"
|
|||||||
SENSOR_UNITS = {
|
SENSOR_UNITS = {
|
||||||
SENSOR_SMS: "unread",
|
SENSOR_SMS: "unread",
|
||||||
SENSOR_SMS_TOTAL: "messages",
|
SENSOR_SMS_TOTAL: "messages",
|
||||||
SENSOR_USAGE: DATA_MEBIBYTES,
|
SENSOR_USAGE: UnitOfInformation.MEBIBYTES,
|
||||||
"radio_quality": PERCENTAGE,
|
"radio_quality": PERCENTAGE,
|
||||||
"rx_level": SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
"rx_level": SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
"tx_level": SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
"tx_level": SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||||
|
Loading…
Reference in New Issue
Block a user