Deprecate aux_heat in elkm1 (#125372)
* Deprecate aux_heat in elkm1 * Update homeassistant/components/elkm1/switch.py --------- Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>pull/125045/head^2
parent
26ede9a679
commit
84def0c041
|
@ -20,8 +20,9 @@ from homeassistant.components.climate import (
|
||||||
from homeassistant.const import PRECISION_WHOLE
|
from homeassistant.const import PRECISION_WHOLE
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
|
||||||
|
|
||||||
from . import ElkEntity, ElkM1ConfigEntry, create_elk_entities
|
from . import DOMAIN, ElkEntity, ElkM1ConfigEntry, create_elk_entities
|
||||||
|
|
||||||
SUPPORT_HVAC = [
|
SUPPORT_HVAC = [
|
||||||
HVACMode.OFF,
|
HVACMode.OFF,
|
||||||
|
@ -151,10 +152,30 @@ class ElkThermostat(ElkEntity, ClimateEntity):
|
||||||
|
|
||||||
async def async_turn_aux_heat_on(self) -> None:
|
async def async_turn_aux_heat_on(self) -> None:
|
||||||
"""Turn auxiliary heater on."""
|
"""Turn auxiliary heater on."""
|
||||||
|
async_create_issue(
|
||||||
|
self.hass,
|
||||||
|
DOMAIN,
|
||||||
|
"migrate_aux_heat",
|
||||||
|
breaks_in_ha_version="2025.4.0",
|
||||||
|
is_fixable=True,
|
||||||
|
is_persistent=True,
|
||||||
|
translation_key="migrate_aux_heat",
|
||||||
|
severity=IssueSeverity.WARNING,
|
||||||
|
)
|
||||||
self._elk_set(ThermostatMode.EMERGENCY_HEAT, None)
|
self._elk_set(ThermostatMode.EMERGENCY_HEAT, None)
|
||||||
|
|
||||||
async def async_turn_aux_heat_off(self) -> None:
|
async def async_turn_aux_heat_off(self) -> None:
|
||||||
"""Turn auxiliary heater off."""
|
"""Turn auxiliary heater off."""
|
||||||
|
async_create_issue(
|
||||||
|
self.hass,
|
||||||
|
DOMAIN,
|
||||||
|
"migrate_aux_heat",
|
||||||
|
breaks_in_ha_version="2025.4.0",
|
||||||
|
is_fixable=True,
|
||||||
|
is_persistent=True,
|
||||||
|
translation_key="migrate_aux_heat",
|
||||||
|
severity=IssueSeverity.WARNING,
|
||||||
|
)
|
||||||
self._elk_set(ThermostatMode.HEAT, None)
|
self._elk_set(ThermostatMode.HEAT, None)
|
||||||
|
|
||||||
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
async def async_set_fan_mode(self, fan_mode: str) -> None:
|
||||||
|
|
|
@ -189,5 +189,18 @@
|
||||||
"name": "Sensor zone trigger",
|
"name": "Sensor zone trigger",
|
||||||
"description": "Triggers zone."
|
"description": "Triggers zone."
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"issues": {
|
||||||
|
"migrate_aux_heat": {
|
||||||
|
"title": "Migration of Elk-M1 set_aux_heat action",
|
||||||
|
"fix_flow": {
|
||||||
|
"step": {
|
||||||
|
"confirm": {
|
||||||
|
"description": "The Elk-M1 `set_aux_heat` action has been migrated. A new emergency heat switch entity is available for each thermostat.\n\nUpdate any automations to use the new emergency heat switch entity. When this is done, Press submit to fix this issue.",
|
||||||
|
"title": "[%key:component::elkm1::issues::migrate_aux_heat::title%]"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,13 +4,18 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from elkm1_lib.const import ThermostatMode, ThermostatSetting
|
||||||
|
from elkm1_lib.elements import Element
|
||||||
|
from elkm1_lib.elk import Elk
|
||||||
from elkm1_lib.outputs import Output
|
from elkm1_lib.outputs import Output
|
||||||
|
from elkm1_lib.thermostats import Thermostat
|
||||||
|
|
||||||
from homeassistant.components.switch import SwitchEntity
|
from homeassistant.components.switch import SwitchEntity
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||||
|
|
||||||
from . import ElkAttachedEntity, ElkEntity, ElkM1ConfigEntry, create_elk_entities
|
from . import ElkAttachedEntity, ElkEntity, ElkM1ConfigEntry, create_elk_entities
|
||||||
|
from .models import ELKM1Data
|
||||||
|
|
||||||
|
|
||||||
async def async_setup_entry(
|
async def async_setup_entry(
|
||||||
|
@ -23,6 +28,9 @@ async def async_setup_entry(
|
||||||
elk = elk_data.elk
|
elk = elk_data.elk
|
||||||
entities: list[ElkEntity] = []
|
entities: list[ElkEntity] = []
|
||||||
create_elk_entities(elk_data, elk.outputs, "output", ElkOutput, entities)
|
create_elk_entities(elk_data, elk.outputs, "output", ElkOutput, entities)
|
||||||
|
create_elk_entities(
|
||||||
|
elk_data, elk.thermostats, "thermostat", ElkThermostatEMHeat, entities
|
||||||
|
)
|
||||||
async_add_entities(entities)
|
async_add_entities(entities)
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,3 +51,32 @@ class ElkOutput(ElkAttachedEntity, SwitchEntity):
|
||||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
"""Turn off the output."""
|
"""Turn off the output."""
|
||||||
self._element.turn_off()
|
self._element.turn_off()
|
||||||
|
|
||||||
|
|
||||||
|
class ElkThermostatEMHeat(ElkEntity, SwitchEntity):
|
||||||
|
"""Elk Thermostat emergency heat as switch."""
|
||||||
|
|
||||||
|
_element: Thermostat
|
||||||
|
|
||||||
|
def __init__(self, element: Element, elk: Elk, elk_data: ELKM1Data) -> None:
|
||||||
|
"""Initialize the emergency heat switch."""
|
||||||
|
super().__init__(element, elk, elk_data)
|
||||||
|
self._unique_id = f"{self._unique_id}emheat"
|
||||||
|
self._attr_name = f"{element.name} emergency heat"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_on(self) -> bool:
|
||||||
|
"""Get the current emergency heat status."""
|
||||||
|
return self._element.mode == ThermostatMode.EMERGENCY_HEAT
|
||||||
|
|
||||||
|
def _elk_set(self, mode: ThermostatMode) -> None:
|
||||||
|
"""Set the thermostat mode."""
|
||||||
|
self._element.set(ThermostatSetting.MODE, mode)
|
||||||
|
|
||||||
|
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||||
|
"""Turn on the output."""
|
||||||
|
self._elk_set(ThermostatMode.EMERGENCY_HEAT)
|
||||||
|
|
||||||
|
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||||
|
"""Turn off the output."""
|
||||||
|
self._elk_set(ThermostatMode.EMERGENCY_HEAT)
|
||||||
|
|
Loading…
Reference in New Issue