Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/melcloud/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "MELCloud",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/melcloud",
"requirements": ["pymelcloud==2.0.0"],
"requirements": ["pymelcloud==2.1.0"],
"dependencies": [],
"codeowners": ["@vilppuvuorinen"]
}
12 changes: 8 additions & 4 deletions homeassistant/components/melcloud/sensor.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
"""Support for MelCloud device sensors."""
import logging

from pymelcloud import DEVICE_TYPE_ATA, AtaDevice
from pymelcloud import DEVICE_TYPE_ATA

from homeassistant.const import DEVICE_CLASS_TEMPERATURE, TEMP_CELSIUS
from homeassistant.helpers.entity import Entity
from homeassistant.util.unit_system import UnitSystem

from . import MelCloudDevice
from .const import DOMAIN, TEMP_UNIT_LOOKUP

ATTR_MEASUREMENT_NAME = "measurement_name"
ATTR_ICON = "icon"
ATTR_UNIT_FN = "unit_fn"
ATTR_DEVICE_CLASS = "device_class"
ATTR_VALUE_FN = "value_fn"
ATTR_ENABLED_FN = "enabled"

SENSORS = {
"room_temperature": {
Expand All @@ -22,13 +23,15 @@
ATTR_UNIT_FN: lambda x: TEMP_UNIT_LOOKUP.get(x.device.temp_unit, TEMP_CELSIUS),
ATTR_DEVICE_CLASS: DEVICE_CLASS_TEMPERATURE,
ATTR_VALUE_FN: lambda x: x.device.room_temperature,
ATTR_ENABLED_FN: lambda x: True,
},
"energy": {
ATTR_MEASUREMENT_NAME: "Energy",
ATTR_ICON: "mdi:factory",
ATTR_UNIT_FN: lambda x: "kWh",
ATTR_DEVICE_CLASS: None,
ATTR_VALUE_FN: lambda x: x.device.total_energy_consumed,
ATTR_ENABLED_FN: lambda x: x.device.has_energy_consumed_meter,
},
}

Expand All @@ -40,9 +43,10 @@ async def async_setup_entry(hass, entry, async_add_entities):
mel_devices = hass.data[DOMAIN].get(entry.entry_id)
async_add_entities(
[
MelCloudSensor(mel_device, measurement, definition, hass.config.units)
MelCloudSensor(mel_device, measurement, definition)
for measurement, definition in SENSORS.items()
for mel_device in mel_devices[DEVICE_TYPE_ATA]
if definition[ATTR_ENABLED_FN](mel_device)
],
True,
)
Expand All @@ -51,7 +55,7 @@ async def async_setup_entry(hass, entry, async_add_entities):
class MelCloudSensor(Entity):
"""Representation of a Sensor."""

def __init__(self, device: AtaDevice, measurement, definition, units: UnitSystem):
def __init__(self, device: MelCloudDevice, measurement, definition):
"""Initialize the sensor."""
self._api = device
self._name_slug = device.name
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1361,7 +1361,7 @@ pymailgunner==1.4
pymediaroom==0.6.4

# homeassistant.components.melcloud
pymelcloud==2.0.0
pymelcloud==2.1.0

# homeassistant.components.somfy
pymfy==0.7.1
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ pylitejet==0.1
pymailgunner==1.4

# homeassistant.components.melcloud
pymelcloud==2.0.0
pymelcloud==2.1.0

# homeassistant.components.somfy
pymfy==0.7.1
Expand Down