mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Remove entity description in Point (#112921)
This commit is contained in:
parent
d29418ebf5
commit
d0a1781187
@ -2,7 +2,6 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
|
||||
from homeassistant.components.sensor import (
|
||||
@ -24,36 +23,22 @@ from .const import DOMAIN as POINT_DOMAIN, POINT_DISCOVERY_NEW
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class MinutPointRequiredKeysMixin:
|
||||
"""Mixin for required keys."""
|
||||
|
||||
precision: int
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class MinutPointSensorEntityDescription(
|
||||
SensorEntityDescription, MinutPointRequiredKeysMixin
|
||||
):
|
||||
"""Describes MinutPoint sensor entity."""
|
||||
|
||||
|
||||
SENSOR_TYPES: tuple[MinutPointSensorEntityDescription, ...] = (
|
||||
MinutPointSensorEntityDescription(
|
||||
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
||||
SensorEntityDescription(
|
||||
key="temperature",
|
||||
precision=1,
|
||||
suggested_display_precision=1,
|
||||
device_class=SensorDeviceClass.TEMPERATURE,
|
||||
native_unit_of_measurement=UnitOfTemperature.CELSIUS,
|
||||
),
|
||||
MinutPointSensorEntityDescription(
|
||||
SensorEntityDescription(
|
||||
key="humidity",
|
||||
precision=1,
|
||||
suggested_display_precision=1,
|
||||
device_class=SensorDeviceClass.HUMIDITY,
|
||||
native_unit_of_measurement=PERCENTAGE,
|
||||
),
|
||||
MinutPointSensorEntityDescription(
|
||||
SensorEntityDescription(
|
||||
key="sound",
|
||||
precision=1,
|
||||
suggested_display_precision=1,
|
||||
device_class=SensorDeviceClass.SOUND_PRESSURE,
|
||||
native_unit_of_measurement=UnitOfSoundPressure.WEIGHTED_DECIBEL_A,
|
||||
),
|
||||
@ -86,10 +71,8 @@ async def async_setup_entry(
|
||||
class MinutPointSensor(MinutPointEntity, SensorEntity):
|
||||
"""The platform class required by Home Assistant."""
|
||||
|
||||
entity_description: MinutPointSensorEntityDescription
|
||||
|
||||
def __init__(
|
||||
self, point_client, device_id, description: MinutPointSensorEntityDescription
|
||||
self, point_client, device_id, description: SensorEntityDescription
|
||||
) -> None:
|
||||
"""Initialize the sensor."""
|
||||
super().__init__(point_client, device_id, description.device_class)
|
||||
@ -100,9 +83,5 @@ class MinutPointSensor(MinutPointEntity, SensorEntity):
|
||||
_LOGGER.debug("Update sensor value for %s", self)
|
||||
if self.is_updated:
|
||||
self._attr_native_value = await self.device.sensor(self.device_class)
|
||||
if self.native_value is not None:
|
||||
self._attr_native_value = round(
|
||||
self.native_value, self.entity_description.precision
|
||||
)
|
||||
self._updated = parse_datetime(self.device.last_update)
|
||||
self.async_write_ha_state()
|
||||
|
Loading…
x
Reference in New Issue
Block a user