mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Use new enums in melcloud (#61894)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
3ac585ea2d
commit
c9132b229d
@ -9,12 +9,10 @@ from pymelcloud import DEVICE_TYPE_ATA, DEVICE_TYPE_ATW
|
|||||||
from pymelcloud.atw_device import Zone
|
from pymelcloud.atw_device import Zone
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
DEVICE_CLASS_ENERGY,
|
SensorDeviceClass,
|
||||||
DEVICE_CLASS_TEMPERATURE,
|
|
||||||
STATE_CLASS_MEASUREMENT,
|
|
||||||
STATE_CLASS_TOTAL_INCREASING,
|
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS
|
from homeassistant.const import ENERGY_KILO_WATT_HOUR, TEMP_CELSIUS
|
||||||
|
|
||||||
@ -43,7 +41,7 @@ ATA_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
|
|||||||
name="Room Temperature",
|
name="Room Temperature",
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
value_fn=lambda x: x.device.room_temperature,
|
value_fn=lambda x: x.device.room_temperature,
|
||||||
enabled=lambda x: True,
|
enabled=lambda x: True,
|
||||||
),
|
),
|
||||||
@ -52,7 +50,7 @@ ATA_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
|
|||||||
name="Energy",
|
name="Energy",
|
||||||
icon="mdi:factory",
|
icon="mdi:factory",
|
||||||
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
value_fn=lambda x: x.device.total_energy_consumed,
|
value_fn=lambda x: x.device.total_energy_consumed,
|
||||||
enabled=lambda x: x.device.has_energy_consumed_meter,
|
enabled=lambda x: x.device.has_energy_consumed_meter,
|
||||||
),
|
),
|
||||||
@ -63,7 +61,7 @@ ATW_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
|
|||||||
name="Outside Temperature",
|
name="Outside Temperature",
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
value_fn=lambda x: x.device.outside_temperature,
|
value_fn=lambda x: x.device.outside_temperature,
|
||||||
enabled=lambda x: True,
|
enabled=lambda x: True,
|
||||||
),
|
),
|
||||||
@ -72,7 +70,7 @@ ATW_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
|
|||||||
name="Tank Temperature",
|
name="Tank Temperature",
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
value_fn=lambda x: x.device.tank_temperature,
|
value_fn=lambda x: x.device.tank_temperature,
|
||||||
enabled=lambda x: True,
|
enabled=lambda x: True,
|
||||||
),
|
),
|
||||||
@ -83,7 +81,7 @@ ATW_ZONE_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
|
|||||||
name="Room Temperature",
|
name="Room Temperature",
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
value_fn=lambda zone: zone.room_temperature,
|
value_fn=lambda zone: zone.room_temperature,
|
||||||
enabled=lambda x: True,
|
enabled=lambda x: True,
|
||||||
),
|
),
|
||||||
@ -92,7 +90,7 @@ ATW_ZONE_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
|
|||||||
name="Flow Temperature",
|
name="Flow Temperature",
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
value_fn=lambda zone: zone.flow_temperature,
|
value_fn=lambda zone: zone.flow_temperature,
|
||||||
enabled=lambda x: True,
|
enabled=lambda x: True,
|
||||||
),
|
),
|
||||||
@ -101,7 +99,7 @@ ATW_ZONE_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
|
|||||||
name="Flow Return Temperature",
|
name="Flow Return Temperature",
|
||||||
icon="mdi:thermometer",
|
icon="mdi:thermometer",
|
||||||
native_unit_of_measurement=TEMP_CELSIUS,
|
native_unit_of_measurement=TEMP_CELSIUS,
|
||||||
device_class=DEVICE_CLASS_TEMPERATURE,
|
device_class=SensorDeviceClass.TEMPERATURE,
|
||||||
value_fn=lambda zone: zone.return_temperature,
|
value_fn=lambda zone: zone.return_temperature,
|
||||||
enabled=lambda x: True,
|
enabled=lambda x: True,
|
||||||
),
|
),
|
||||||
@ -152,10 +150,10 @@ class MelDeviceSensor(SensorEntity):
|
|||||||
self._attr_name = f"{api.name} {description.name}"
|
self._attr_name = f"{api.name} {description.name}"
|
||||||
self._attr_unique_id = f"{api.device.serial}-{api.device.mac}-{description.key}"
|
self._attr_unique_id = f"{api.device.serial}-{api.device.mac}-{description.key}"
|
||||||
|
|
||||||
if description.device_class == DEVICE_CLASS_ENERGY:
|
if description.device_class == SensorDeviceClass.ENERGY:
|
||||||
self._attr_state_class = STATE_CLASS_TOTAL_INCREASING
|
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||||
else:
|
else:
|
||||||
self._attr_state_class = STATE_CLASS_MEASUREMENT
|
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user