Skip to content

Commit

Permalink
Deprecate aux_heat in econet (#125365)
Browse files Browse the repository at this point in the history
* Deprecate aux_heat in econet

* strings

* Use generator
  • Loading branch information
gjohansson-ST authored Sep 8, 2024
1 parent c2d5696 commit a7a219b
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
1 change: 1 addition & 0 deletions homeassistant/components/econet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
Platform.BINARY_SENSOR,
Platform.CLIMATE,
Platform.SENSOR,
Platform.SWITCH,
Platform.WATER_HEATER,
]
PUSH_UPDATE = "econet.push_update"
Expand Down
21 changes: 21 additions & 0 deletions homeassistant/components/econet/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from homeassistant.const import ATTR_TEMPERATURE, UnitOfTemperature
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue

from . import EcoNetEntity
from .const import DOMAIN, EQUIPMENT
Expand Down Expand Up @@ -203,10 +204,30 @@ def set_fan_mode(self, fan_mode: str) -> None:

def turn_aux_heat_on(self) -> None:
"""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._econet.set_mode(ThermostatOperationMode.EMERGENCY_HEAT)

def turn_aux_heat_off(self) -> None:
"""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._econet.set_mode(ThermostatOperationMode.HEATING)

@property
Expand Down
13 changes: 13 additions & 0 deletions homeassistant/components/econet/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,18 @@
}
}
}
},
"issues": {
"migrate_aux_heat": {
"title": "Migration of EcoNet set_aux_heat action",
"fix_flow": {
"step": {
"confirm": {
"description": "The EcoNet `set_aux_heat` action has been migrated. A new `aux_heat_only` switch entity is available for each thermostat.\n\nUpdate any automations to use the new `aux_heat_only` switch entity. When this is done, Press submit to fix this issue.",
"title": "[%key:component::econet::issues::migrate_aux_heat::title%]"
}
}
}
}
}
}
57 changes: 57 additions & 0 deletions homeassistant/components/econet/switch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
"""Support for using switch with ecoNet thermostats."""

from __future__ import annotations

import logging
from typing import Any

from pyeconet.equipment import EquipmentType
from pyeconet.equipment.thermostat import ThermostatOperationMode

from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

from . import EcoNetEntity
from .const import DOMAIN, EQUIPMENT

_LOGGER = logging.getLogger(__name__)


async def async_setup_entry(
hass: HomeAssistant,
entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up the ecobee thermostat switch entity."""
equipment = hass.data[DOMAIN][EQUIPMENT][entry.entry_id]
async_add_entities(
EcoNetSwitchAuxHeatOnly(thermostat)
for thermostat in equipment[EquipmentType.THERMOSTAT]
)


class EcoNetSwitchAuxHeatOnly(EcoNetEntity, SwitchEntity):
"""Representation of a aux_heat_only EcoNet switch."""

def __init__(self, thermostat) -> None:
"""Initialize EcoNet ventilator platform."""
super().__init__(thermostat)
self._attr_name = f"{thermostat.device_name} emergency heat"
self._attr_unique_id = (
f"{thermostat.device_id}_{thermostat.device_name}_auxheat"
)

def turn_on(self, **kwargs: Any) -> None:
"""Set the hvacMode to auxHeatOnly."""
self._econet.set_mode(ThermostatOperationMode.EMERGENCY_HEAT)

def turn_off(self, **kwargs: Any) -> None:
"""Set the hvacMode back to the prior setting."""
self._econet.set_mode(ThermostatOperationMode.HEATING)

@property
def is_on(self) -> bool:
"""Return true if auxHeatOnly mode is active."""
return self._econet.mode == ThermostatOperationMode.EMERGENCY_HEAT

0 comments on commit a7a219b

Please sign in to comment.