Add daily energy consumption sensor for melcloud (#78682)

This commit is contained in:
Vilppu Vuorinen 2022-09-28 15:45:14 +03:00 committed by GitHub
parent 253647aaa9
commit e39c4db438
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 3 deletions

View File

@ -141,6 +141,11 @@ class MelCloudDevice:
name=self.name,
)
@property
def daily_energy_consumed(self) -> float | None:
"""Return energy consumed during the current day in kWh."""
return self.device.daily_energy_consumed
async def mel_devices_setup(hass, token) -> dict[str, list[MelCloudDevice]]:
"""Query connected devices from MELCloud."""

View File

@ -3,7 +3,7 @@
"name": "MELCloud",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/melcloud",
"requirements": ["pymelcloud==2.5.6"],
"requirements": ["pymelcloud==2.5.8"],
"codeowners": ["@vilppuvuorinen"],
"iot_class": "cloud_polling",
"loggers": ["pymelcloud"]

View File

@ -57,6 +57,15 @@ ATA_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
value_fn=lambda x: x.device.total_energy_consumed,
enabled=lambda x: x.device.has_energy_consumed_meter,
),
MelcloudSensorEntityDescription(
key="daily_energy",
name="Daily Energy Consumed",
icon="mdi:factory",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
value_fn=lambda x: x.device.daily_energy_consumed,
enabled=lambda x: True,
),
)
ATW_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
MelcloudSensorEntityDescription(
@ -77,6 +86,15 @@ ATW_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
value_fn=lambda x: x.device.tank_temperature,
enabled=lambda x: True,
),
MelcloudSensorEntityDescription(
key="daily_energy",
name="Daily Energy Consumed",
icon="mdi:factory",
native_unit_of_measurement=ENERGY_KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
value_fn=lambda x: x.device.daily_energy_consumed,
enabled=lambda x: True,
),
)
ATW_ZONE_SENSORS: tuple[MelcloudSensorEntityDescription, ...] = (
MelcloudSensorEntityDescription(

View File

@ -1703,7 +1703,7 @@ pymazda==0.3.7
pymediaroom==0.6.5.4
# homeassistant.components.melcloud
pymelcloud==2.5.6
pymelcloud==2.5.8
# homeassistant.components.meteoclimatic
pymeteoclimatic==0.0.6

View File

@ -1198,7 +1198,7 @@ pymata-express==1.19
pymazda==0.3.7
# homeassistant.components.melcloud
pymelcloud==2.5.6
pymelcloud==2.5.8
# homeassistant.components.meteoclimatic
pymeteoclimatic==0.0.6