Use DataRate unit and device class in integrations (#83610)

This commit is contained in:
epenet
2022-12-10 11:41:44 +01:00
committed by GitHub
parent 3970da0ad3
commit 535aba10ee
21 changed files with 132 additions and 111 deletions

View File

@@ -3,8 +3,8 @@ from __future__ import annotations
from typing import Any
from homeassistant.components.sensor import SensorEntity
from homeassistant.const import DATA_RATE_MEGABITS_PER_SECOND
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
from homeassistant.const import UnitOfDataRate
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
@@ -13,8 +13,6 @@ from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from . import DATA_UPDATED, DOMAIN as FASTDOTCOM_DOMAIN
ICON = "mdi:speedometer"
async def async_setup_platform(
hass: HomeAssistant,
@@ -30,8 +28,9 @@ class SpeedtestSensor(RestoreEntity, SensorEntity):
"""Implementation of a FAst.com sensor."""
_attr_name = "Fast.com Download"
_attr_native_unit_of_measurement = DATA_RATE_MEGABITS_PER_SECOND
_attr_icon = ICON
_attr_device_class = SensorDeviceClass.DATA_RATE
_attr_native_unit_of_measurement = UnitOfDataRate.MEGABITS_PER_SECOND
_attr_icon = "mdi:speedometer"
_attr_should_poll = False
_attr_native_value = None