1 """Support for using switch with ecobee thermostats."""
3 from __future__
import annotations
5 from datetime
import tzinfo
16 from .
import EcobeeData
17 from .climate
import HASS_TO_ECOBEE_HVAC
18 from .const
import DOMAIN, ECOBEE_AUX_HEAT_ONLY
19 from .entity
import EcobeeBaseEntity
21 _LOGGER = logging.getLogger(__name__)
23 DATE_FORMAT =
"%Y-%m-%d %H:%M:%S"
28 config_entry: ConfigEntry,
29 async_add_entities: AddEntitiesCallback,
31 """Set up the ecobee thermostat switch entity."""
32 data: EcobeeData = hass.data[DOMAIN]
34 entities: list[SwitchEntity] = [
38 (await dt_util.async_get_time_zone(thermostat[
"location"][
"timeZone"]))
39 or dt_util.get_default_time_zone(),
41 for index, thermostat
in enumerate(data.ecobee.thermostats)
42 if thermostat[
"settings"][
"ventilatorType"] !=
"none"
48 for index, thermostat
in enumerate(data.ecobee.thermostats)
49 if thermostat[
"settings"][
"hasHeatPump"]
57 """A Switch class, representing 20 min timer for an ecobee thermostat with ventilator attached."""
59 _attr_has_entity_name =
True
60 _attr_name =
"Ventilator 20m Timer"
65 thermostat_index: int,
66 operating_timezone: tzinfo,
68 """Initialize ecobee ventilator platform."""
69 super().
__init__(data, thermostat_index)
70 self.
_attr_unique_id_attr_unique_id = f
"{self.base_unique_id}_ventilator_20m_timer"
76 """Get the latest state from the thermostat."""
84 ventilator_off_date_time = self.
thermostatthermostat[
"settings"][
"ventilatorOffDateTime"]
86 self.
_attr_is_on_attr_is_on = ventilator_off_date_time
and dt_util.parse_datetime(
87 ventilator_off_date_time, raise_on_error=
True
93 """Set ventilator 20 min timer on."""
94 await self.
hasshass.async_add_executor_job(
100 """Set ventilator 20 min timer off."""
101 await self.
hasshass.async_add_executor_job(
108 """Representation of a aux_heat_only ecobee switch."""
110 _attr_has_entity_name =
True
111 _attr_translation_key =
"aux_heat_only"
116 thermostat_index: int,
118 """Initialize ecobee ventilator platform."""
119 super().
__init__(data, thermostat_index)
127 """Set the hvacMode to auxHeatOnly."""
132 """Set the hvacMode back to the prior setting."""
133 self.
datadata.ecobee.set_hvac_mode(
139 """Return true if auxHeatOnly mode is active."""
140 return self.
thermostatthermostat[
"settings"][
"hvacMode"] == ECOBEE_AUX_HEAT_ONLY
dict[str, Any] thermostat(self)
_last_hvac_mode_before_aux_heat
None turn_on(self, **Any kwargs)
None __init__(self, EcobeeData data, int thermostat_index)
None turn_off(self, **Any kwargs)
None async_turn_on(self, **Any kwargs)
None __init__(self, EcobeeData data, int thermostat_index, tzinfo operating_timezone)
None async_turn_off(self, **Any kwargs)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)
IssData update(pyiss.ISS iss)