mirror of
https://github.com/home-assistant/core.git
synced 2025-07-09 14:27:07 +00:00
More cleanup in Plugwise sensor (#66274)
This commit is contained in:
parent
f5829173db
commit
08ab00d3ab
@ -17,10 +17,10 @@ from homeassistant.const import (
|
|||||||
TEMP_CELSIUS,
|
TEMP_CELSIUS,
|
||||||
VOLUME_CUBIC_METERS,
|
VOLUME_CUBIC_METERS,
|
||||||
)
|
)
|
||||||
from homeassistant.core import HomeAssistant, callback
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from .const import DOMAIN, LOGGER, UNIT_LUMEN
|
from .const import DOMAIN, UNIT_LUMEN
|
||||||
from .coordinator import PlugwiseDataUpdateCoordinator
|
from .coordinator import PlugwiseDataUpdateCoordinator
|
||||||
from .entity import PlugwiseEntity
|
from .entity import PlugwiseEntity
|
||||||
|
|
||||||
@ -74,13 +74,6 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
),
|
),
|
||||||
SensorEntityDescription(
|
|
||||||
key="return_temperature",
|
|
||||||
name="Return Temperature",
|
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
|
||||||
device_class=SensorDeviceClass.TEMPERATURE,
|
|
||||||
state_class=SensorStateClass.MEASUREMENT,
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
SensorEntityDescription(
|
||||||
key="electricity_consumed",
|
key="electricity_consumed",
|
||||||
name="Electricity Consumed",
|
name="Electricity Consumed",
|
||||||
@ -258,17 +251,6 @@ SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
INDICATE_ACTIVE_LOCAL_DEVICE_SENSORS: tuple[SensorEntityDescription, ...] = (
|
|
||||||
SensorEntityDescription(
|
|
||||||
key="cooling_state",
|
|
||||||
name="Cooling State",
|
|
||||||
),
|
|
||||||
SensorEntityDescription(
|
|
||||||
key="flame_state",
|
|
||||||
name="Flame State",
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
@ -313,13 +295,7 @@ class PlugwiseSensorEnity(PlugwiseEntity, SensorEntity):
|
|||||||
self._attr_unique_id = f"{device_id}-{description.key}"
|
self._attr_unique_id = f"{device_id}-{description.key}"
|
||||||
self._attr_name = (f"{self.device.get('name', '')} {description.name}").lstrip()
|
self._attr_name = (f"{self.device.get('name', '')} {description.name}").lstrip()
|
||||||
|
|
||||||
@callback
|
@property
|
||||||
def _handle_coordinator_update(self) -> None:
|
def native_value(self) -> int | float | None:
|
||||||
"""Handle updated data from the coordinator."""
|
"""Return the value reported by the sensor."""
|
||||||
if not (data := self.coordinator.data.devices.get(self._dev_id)):
|
return self.device["sensors"].get(self.entity_description.key)
|
||||||
LOGGER.error("Received no data for device %s", self._dev_id)
|
|
||||||
super()._handle_coordinator_update()
|
|
||||||
return
|
|
||||||
|
|
||||||
self._attr_native_value = data["sensors"].get(self.entity_description.key)
|
|
||||||
super()._handle_coordinator_update()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user