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
18 changes: 6 additions & 12 deletions homeassistant/components/melcloud/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from homeassistant.const import TEMP_CELSIUS
from homeassistant.helpers import config_validation as cv, entity_platform
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.util.temperature import convert as convert_temperature

from . import MelCloudDevice
from .const import (
Expand All @@ -44,7 +43,6 @@
DOMAIN,
SERVICE_SET_VANE_HORIZONTAL,
SERVICE_SET_VANE_VERTICAL,
TEMP_UNIT_LOOKUP,
)

SCAN_INTERVAL = timedelta(seconds=60)
Expand Down Expand Up @@ -169,7 +167,7 @@ def device_state_attributes(self) -> Optional[Dict[str, Any]]:
@property
def temperature_unit(self) -> str:
"""Return the unit of measurement used by the platform."""
return TEMP_UNIT_LOOKUP.get(self._device.temp_unit, TEMP_CELSIUS)
return TEMP_CELSIUS

@property
def hvac_mode(self) -> str:
Expand Down Expand Up @@ -281,9 +279,7 @@ def min_temp(self) -> float:
if min_value is not None:
return min_value

return convert_temperature(
DEFAULT_MIN_TEMP, TEMP_CELSIUS, self.temperature_unit
)
return DEFAULT_MIN_TEMP

@property
def max_temp(self) -> float:
Expand All @@ -292,9 +288,7 @@ def max_temp(self) -> float:
if max_value is not None:
return max_value

return convert_temperature(
DEFAULT_MAX_TEMP, TEMP_CELSIUS, self.temperature_unit
)
return DEFAULT_MAX_TEMP


class AtwDeviceZoneClimate(MelCloudClimate):
Expand Down Expand Up @@ -331,7 +325,7 @@ def device_state_attributes(self) -> Dict[str, Any]:
@property
def temperature_unit(self) -> str:
"""Return the unit of measurement used by the platform."""
return TEMP_UNIT_LOOKUP.get(self._device.temp_unit, TEMP_CELSIUS)
return TEMP_CELSIUS

@property
def hvac_mode(self) -> str:
Expand Down Expand Up @@ -391,12 +385,12 @@ def min_temp(self) -> float:

MELCloud API does not expose radiator zone temperature limits.
"""
return convert_temperature(10, TEMP_CELSIUS, self.temperature_unit)
return 10

@property
def max_temp(self) -> float:
"""Return the maximum temperature.

MELCloud API does not expose radiator zone temperature limits.
"""
return convert_temperature(30, TEMP_CELSIUS, self.temperature_unit)
return 30
9 changes: 0 additions & 9 deletions homeassistant/components/melcloud/const.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
"""Constants for the MELCloud Climate integration."""
from pymelcloud.const import UNIT_TEMP_CELSIUS, UNIT_TEMP_FAHRENHEIT

from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT

DOMAIN = "melcloud"

Expand All @@ -15,9 +12,3 @@

SERVICE_SET_VANE_HORIZONTAL = "set_vane_horizontal"
SERVICE_SET_VANE_VERTICAL = "set_vane_vertical"

TEMP_UNIT_LOOKUP = {
UNIT_TEMP_CELSIUS: TEMP_CELSIUS,
UNIT_TEMP_FAHRENHEIT: TEMP_FAHRENHEIT,
}
TEMP_UNIT_REVERSE_LOOKUP = {v: k for k, v in TEMP_UNIT_LOOKUP.items()}
16 changes: 8 additions & 8 deletions homeassistant/components/melcloud/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
from homeassistant.helpers.entity import Entity

from . import MelCloudDevice
from .const import DOMAIN, TEMP_UNIT_LOOKUP
from .const import DOMAIN

ATTR_MEASUREMENT_NAME = "measurement_name"
ATTR_ICON = "icon"
ATTR_UNIT_FN = "unit_fn"
ATTR_UNIT = "unit"
ATTR_DEVICE_CLASS = "device_class"
ATTR_VALUE_FN = "value_fn"
ATTR_ENABLED_FN = "enabled"
Expand All @@ -25,15 +25,15 @@
"room_temperature": {
ATTR_MEASUREMENT_NAME: "Room Temperature",
ATTR_ICON: "mdi:thermometer",
ATTR_UNIT_FN: lambda x: TEMP_UNIT_LOOKUP.get(x.device.temp_unit, TEMP_CELSIUS),
ATTR_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: ENERGY_KILO_WATT_HOUR,
ATTR_UNIT: ENERGY_KILO_WATT_HOUR,
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 @@ -43,15 +43,15 @@
"outside_temperature": {
ATTR_MEASUREMENT_NAME: "Outside Temperature",
ATTR_ICON: "mdi:thermometer",
ATTR_UNIT_FN: lambda x: TEMP_UNIT_LOOKUP.get(x.device.temp_unit, TEMP_CELSIUS),
ATTR_UNIT: TEMP_CELSIUS,
ATTR_DEVICE_CLASS: DEVICE_CLASS_TEMPERATURE,
ATTR_VALUE_FN: lambda x: x.device.outside_temperature,
ATTR_ENABLED_FN: lambda x: True,
},
"tank_temperature": {
ATTR_MEASUREMENT_NAME: "Tank Temperature",
ATTR_ICON: "mdi:thermometer",
ATTR_UNIT_FN: lambda x: TEMP_UNIT_LOOKUP.get(x.device.temp_unit, TEMP_CELSIUS),
ATTR_UNIT: TEMP_CELSIUS,
ATTR_DEVICE_CLASS: DEVICE_CLASS_TEMPERATURE,
ATTR_VALUE_FN: lambda x: x.device.tank_temperature,
ATTR_ENABLED_FN: lambda x: True,
Expand All @@ -61,7 +61,7 @@
"room_temperature": {
ATTR_MEASUREMENT_NAME: "Room Temperature",
ATTR_ICON: "mdi:thermometer",
ATTR_UNIT_FN: lambda x: TEMP_UNIT_LOOKUP.get(x.device.temp_unit, TEMP_CELSIUS),
ATTR_UNIT: TEMP_CELSIUS,
ATTR_DEVICE_CLASS: DEVICE_CLASS_TEMPERATURE,
ATTR_VALUE_FN: lambda zone: zone.room_temperature,
ATTR_ENABLED_FN: lambda x: True,
Expand Down Expand Up @@ -147,7 +147,7 @@ def state(self):
@property
def unit_of_measurement(self):
"""Return the unit of measurement."""
return self._def[ATTR_UNIT_FN](self._api)
return self._def[ATTR_UNIT]

@property
def device_class(self):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/melcloud/water_heater.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from homeassistant.helpers.typing import HomeAssistantType

from . import DOMAIN, MelCloudDevice
from .const import ATTR_STATUS, TEMP_UNIT_LOOKUP
from .const import ATTR_STATUS


async def async_setup_entry(
Expand Down Expand Up @@ -80,7 +80,7 @@ def device_state_attributes(self):
@property
def temperature_unit(self) -> str:
"""Return the unit of measurement used by the platform."""
return TEMP_UNIT_LOOKUP.get(self._device.temp_unit, TEMP_CELSIUS)
return TEMP_CELSIUS

@property
def current_operation(self) -> Optional[str]:
Expand Down