Fix MELCloud temperature unit (#35003)
The MELCLoud API produces and consumes only Celsius.
This commit is contained in:
parent
8ec5e53cf4
commit
66d3832be9
4 changed files with 16 additions and 31 deletions
|
@ -31,7 +31,6 @@ from homeassistant.config_entries import ConfigEntry
|
|||
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 (
|
||||
|
@ -44,7 +43,6 @@ from .const import (
|
|||
DOMAIN,
|
||||
SERVICE_SET_VANE_HORIZONTAL,
|
||||
SERVICE_SET_VANE_VERTICAL,
|
||||
TEMP_UNIT_LOOKUP,
|
||||
)
|
||||
|
||||
SCAN_INTERVAL = timedelta(seconds=60)
|
||||
|
@ -169,7 +167,7 @@ class AtaDeviceClimate(MelCloudClimate):
|
|||
@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:
|
||||
|
@ -281,9 +279,7 @@ class AtaDeviceClimate(MelCloudClimate):
|
|||
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:
|
||||
|
@ -292,9 +288,7 @@ class AtaDeviceClimate(MelCloudClimate):
|
|||
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):
|
||||
|
@ -331,7 +325,7 @@ class AtwDeviceZoneClimate(MelCloudClimate):
|
|||
@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:
|
||||
|
@ -391,7 +385,7 @@ class AtwDeviceZoneClimate(MelCloudClimate):
|
|||
|
||||
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:
|
||||
|
@ -399,4 +393,4 @@ class AtwDeviceZoneClimate(MelCloudClimate):
|
|||
|
||||
MELCloud API does not expose radiator zone temperature limits.
|
||||
"""
|
||||
return convert_temperature(30, TEMP_CELSIUS, self.temperature_unit)
|
||||
return 30
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
@ -15,9 +12,3 @@ ATTR_VANE_VERTICAL_POSITIONS = "vane_vertical_positions"
|
|||
|
||||
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()}
|
||||
|
|
|
@ -12,11 +12,11 @@ from homeassistant.const import (
|
|||
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"
|
||||
|
@ -25,7 +25,7 @@ ATA_SENSORS = {
|
|||
"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,
|
||||
|
@ -33,7 +33,7 @@ ATA_SENSORS = {
|
|||
"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,
|
||||
|
@ -43,7 +43,7 @@ ATW_SENSORS = {
|
|||
"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,
|
||||
|
@ -51,7 +51,7 @@ ATW_SENSORS = {
|
|||
"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,
|
||||
|
@ -61,7 +61,7 @@ ATW_ZONE_SENSORS = {
|
|||
"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,
|
||||
|
@ -147,7 +147,7 @@ class MelDeviceSensor(Entity):
|
|||
@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):
|
||||
|
|
|
@ -18,7 +18,7 @@ from homeassistant.const import TEMP_CELSIUS
|
|||
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(
|
||||
|
@ -80,7 +80,7 @@ class AtwWaterHeater(WaterHeaterDevice):
|
|||
@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]:
|
||||
|
|
Loading…
Add table
Reference in a new issue