Fix power/energy mixup in Youless (#81345)
parent
3afef1f8fe
commit
9dd6d5d0ab
|
@ -39,13 +39,13 @@ async def async_setup_entry(
|
|||
async_add_entities(
|
||||
[
|
||||
GasSensor(coordinator, device),
|
||||
PowerMeterSensor(
|
||||
EnergyMeterSensor(
|
||||
coordinator, device, "low", SensorStateClass.TOTAL_INCREASING
|
||||
),
|
||||
PowerMeterSensor(
|
||||
EnergyMeterSensor(
|
||||
coordinator, device, "high", SensorStateClass.TOTAL_INCREASING
|
||||
),
|
||||
PowerMeterSensor(coordinator, device, "total", SensorStateClass.TOTAL),
|
||||
EnergyMeterSensor(coordinator, device, "total", SensorStateClass.TOTAL),
|
||||
CurrentPowerSensor(coordinator, device),
|
||||
DeliveryMeterSensor(coordinator, device, "low"),
|
||||
DeliveryMeterSensor(coordinator, device, "high"),
|
||||
|
@ -68,10 +68,6 @@ class YoulessBaseSensor(CoordinatorEntity, SensorEntity):
|
|||
) -> None:
|
||||
"""Create the sensor."""
|
||||
super().__init__(coordinator)
|
||||
self._device = device
|
||||
self._device_group = device_group
|
||||
self._sensor_id = sensor_id
|
||||
|
||||
self._attr_unique_id = f"{DOMAIN}_{device}_{sensor_id}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={(DOMAIN, f"{device}_{device_group}")},
|
||||
|
@ -149,10 +145,10 @@ class DeliveryMeterSensor(YoulessBaseSensor):
|
|||
) -> None:
|
||||
"""Instantiate a delivery meter sensor."""
|
||||
super().__init__(
|
||||
coordinator, device, "delivery", "Power delivery", f"delivery_{dev_type}"
|
||||
coordinator, device, "delivery", "Energy delivery", f"delivery_{dev_type}"
|
||||
)
|
||||
self._type = dev_type
|
||||
self._attr_name = f"Power delivery {dev_type}"
|
||||
self._attr_name = f"Energy delivery {dev_type}"
|
||||
|
||||
@property
|
||||
def get_sensor(self) -> YoulessSensor | None:
|
||||
|
@ -163,7 +159,7 @@ class DeliveryMeterSensor(YoulessBaseSensor):
|
|||
return getattr(self.coordinator.data.delivery_meter, f"_{self._type}", None)
|
||||
|
||||
|
||||
class PowerMeterSensor(YoulessBaseSensor):
|
||||
class EnergyMeterSensor(YoulessBaseSensor):
|
||||
"""The Youless low meter value sensor."""
|
||||
|
||||
_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
|
||||
|
@ -177,13 +173,13 @@ class PowerMeterSensor(YoulessBaseSensor):
|
|||
dev_type: str,
|
||||
state_class: SensorStateClass,
|
||||
) -> None:
|
||||
"""Instantiate a power meter sensor."""
|
||||
"""Instantiate a energy meter sensor."""
|
||||
super().__init__(
|
||||
coordinator, device, "power", "Power usage", f"power_{dev_type}"
|
||||
coordinator, device, "power", "Energy usage", f"power_{dev_type}"
|
||||
)
|
||||
self._device = device
|
||||
self._type = dev_type
|
||||
self._attr_name = f"Power {dev_type}"
|
||||
self._attr_name = f"Energy {dev_type}"
|
||||
self._attr_state_class = state_class
|
||||
|
||||
@property
|
||||
|
|
Loading…
Reference in New Issue