Skip to content

Commit

Permalink
Deprecate aux_heat from Nexia climate entity, implement switch (#125250)
Browse files Browse the repository at this point in the history
* Remove deprecated aux_heat from nexia

* Add back aux_heat

* Raise issue
  • Loading branch information
gjohansson-ST authored Sep 8, 2024
1 parent 84def0c commit 2ef37f0
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
22 changes: 22 additions & 0 deletions homeassistant/components/nexia/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
from homeassistant.helpers import entity_platform
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.issue_registry import IssueSeverity, async_create_issue
from homeassistant.helpers.typing import VolDictType

from .const import (
ATTR_AIRCLEANER_MODE,
ATTR_DEHUMIDIFY_SETPOINT,
ATTR_HUMIDIFY_SETPOINT,
ATTR_RUN_MODE,
DOMAIN,
)
from .coordinator import NexiaDataUpdateCoordinator
from .entity import NexiaThermostatZoneEntity
Expand Down Expand Up @@ -378,11 +380,31 @@ async def async_set_preset_mode(self, preset_mode: str) -> None:

async def async_turn_aux_heat_off(self) -> None:
"""Turn Aux Heat 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,
)
await self._thermostat.set_emergency_heat(False)
self._signal_thermostat_update()

async def async_turn_aux_heat_on(self) -> None:
"""Turn Aux Heat 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,
)
await self._thermostat.set_emergency_heat(True)
self._signal_thermostat_update()

Expand Down
13 changes: 13 additions & 0 deletions homeassistant/components/nexia/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,18 @@
}
}
}
},
"issues": {
"migrate_aux_heat": {
"title": "Migration of Nexia set_aux_heat action",
"fix_flow": {
"step": {
"confirm": {
"description": "The Nexia `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 Emergency heat switch entity. When this is done, press submit to fix this issue.",
"title": "[%key:component::nexia::issues::migrate_aux_heat::title%]"
}
}
}
}
}
}
32 changes: 31 additions & 1 deletion homeassistant/components/nexia/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ async def async_setup_entry(
"""Set up switches for a Nexia device."""
coordinator = config_entry.runtime_data
nexia_home = coordinator.nexia_home
entities: list[NexiaHoldSwitch] = []
entities: list[NexiaHoldSwitch | NexiaEmergencyHeatSwitch] = []
for thermostat_id in nexia_home.get_thermostat_ids():
thermostat: NexiaThermostat = nexia_home.get_thermostat_by_id(thermostat_id)
for zone_id in thermostat.get_zone_ids():
zone: NexiaThermostatZone = thermostat.get_zone_by_id(zone_id)
entities.append(NexiaHoldSwitch(coordinator, zone))
if thermostat.has_emergency_heat():
entities.append(NexiaEmergencyHeatSwitch(coordinator, zone))

async_add_entities(entities)

Expand Down Expand Up @@ -64,3 +66,31 @@ async def async_turn_off(self, **kwargs: Any) -> None:
"""Disable permanent hold."""
await self._zone.call_return_to_schedule()
self._signal_zone_update()


class NexiaEmergencyHeatSwitch(NexiaThermostatZoneEntity, SwitchEntity):
"""Provides Nexia emergency heat switch support."""

_attr_translation_key = "emergency_heat"

def __init__(
self, coordinator: NexiaDataUpdateCoordinator, zone: NexiaThermostatZone
) -> None:
"""Initialize the emergency heat mode switch."""
zone_id = zone.zone_id
super().__init__(coordinator, zone, zone_id)

@property
def is_on(self) -> bool:
"""Return if the zone is in hold mode."""
return self._thermostat.is_emergency_heat_active()

async def async_turn_on(self, **kwargs: Any) -> None:
"""Enable permanent hold."""
await self._thermostat.set_emergency_heat(True)
self._signal_thermostat_update()

async def async_turn_off(self, **kwargs: Any) -> None:
"""Disable permanent hold."""
await self._thermostat.set_emergency_heat(False)
self._signal_thermostat_update()

0 comments on commit 2ef37f0

Please sign in to comment.