1 """Support for the Netatmo climate schedule selector."""
3 from __future__
import annotations
20 NETATMO_CREATE_SELECT,
22 from .data_handler
import HOME, SIGNAL_NAME, NetatmoHome
23 from .entity
import NetatmoBaseEntity
25 _LOGGER = logging.getLogger(__name__)
29 hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
31 """Set up the Netatmo energy platform schedule selector."""
34 def _create_entity(netatmo_home: NetatmoHome) ->
None:
38 entry.async_on_unload(
44 """Representation a Netatmo thermostat schedule selector."""
48 def __init__(self, netatmo_home: NetatmoHome) ->
None:
49 """Initialize the select entity."""
50 super().
__init__(netatmo_home.data_handler)
52 self.
homehome = netatmo_home.home
54 self._publishers.extend(
58 "home_id": self.
homehome.entity_id,
59 SIGNAL_NAME: netatmo_home.signal_name,
64 identifiers={(DOMAIN, self.
homehome.entity_id)},
65 name=self.
homehome.name,
66 manufacturer=MANUFACTURER,
68 configuration_url=CONF_URL_ENERGY,
75 schedule.name
for schedule
in self.
homehome.schedules.values()
if schedule.name
85 f
"signal-{DOMAIN}-webhook-{EVENT_TYPE_SCHEDULE}",
92 """Handle webhook events."""
95 if self.
homehome.entity_id != data[
"home_id"]:
98 if data[
"event_type"] == EVENT_TYPE_SCHEDULE
and "schedule_id" in data:
100 self.
hasshass.data[DOMAIN][DATA_SCHEDULES][self.
homehome.entity_id].
get(
108 """Change the selected option."""
109 for sid, schedule
in self.
hasshass.data[DOMAIN][DATA_SCHEDULES][
110 self.
homehome.entity_id
112 if schedule.name != option:
115 "Setting %s schedule to %s (%s)",
116 self.
homehome.entity_id,
120 await self.
homehome.async_switch_schedule(schedule_id=sid)
125 """Update the entity's state."""
127 self.
hasshass.data[DOMAIN][DATA_SCHEDULES][self.
homehome.entity_id] = (
128 self.
homehome.schedules
131 schedule.name
for schedule
in self.
homehome.schedules.values()
if schedule.name
None async_update_callback(self)
None handle_event(self, dict event)
None async_select_option(self, str option)
None __init__(self, NetatmoHome netatmo_home)
None async_added_to_hass(self)
None async_write_ha_state(self)
None async_on_remove(self, CALLBACK_TYPE func)
web.Response get(self, web.Request request, str config_key)
None async_setup_entry(HomeAssistant hass, ConfigEntry entry, AddEntitiesCallback async_add_entities)
Callable[[], None] async_dispatcher_connect(HomeAssistant hass, str signal, Callable[..., Any] target)