1 """Python Control of Nobø Hub - Nobø Energy Control."""
3 from __future__
import annotations
5 from pynobo
import nobo
16 ATTR_HARDWARE_VERSION,
18 ATTR_SOFTWARE_VERSION,
28 config_entry: ConfigEntry,
29 async_add_entities: AddEntitiesCallback,
31 """Set up any temperature sensors connected to the Nobø Ecohub."""
34 hub: nobo = hass.data[DOMAIN][config_entry.entry_id]
37 nobo.API.OVERRIDE_TYPE_NOW
38 if config_entry.options.get(CONF_OVERRIDE_TYPE) == OVERRIDE_TYPE_NOW
39 else nobo.API.OVERRIDE_TYPE_CONSTANT
42 entities: list[SelectEntity] = [
50 """Global override selector for Nobø Ecohub."""
52 _attr_has_entity_name =
True
53 _attr_translation_key =
"global_override"
54 _attr_device_class =
"nobo_hub__override"
55 _attr_should_poll =
False
57 nobo.API.OVERRIDE_MODE_NORMAL:
"none",
58 nobo.API.OVERRIDE_MODE_AWAY:
"away",
59 nobo.API.OVERRIDE_MODE_COMFORT:
"comfort",
60 nobo.API.OVERRIDE_MODE_ECO:
"eco",
62 _attr_options =
list(_modes.values())
63 _attr_current_option: str |
None =
None
65 def __init__(self, hub: nobo, override_type) ->
None:
66 """Initialize the global override selector."""
71 identifiers={(DOMAIN, hub.hub_serial)},
72 name=hub.hub_info[ATTR_NAME],
73 manufacturer=NOBO_MANUFACTURER,
74 model=f
"Nobø Ecohub ({hub.hub_info[ATTR_HARDWARE_VERSION]})",
75 sw_version=hub.hub_info[ATTR_SOFTWARE_VERSION],
79 """Register callback from hub."""
83 """Deregister callback from hub."""
88 mode = [k
for k, v
in self.
_modes_modes.items()
if v == option][0]
90 await self.
_nobo_nobo.async_create_override(
91 mode, self.
_override_type_override_type, nobo.API.OVERRIDE_TARGET_GLOBAL
93 except Exception
as exp:
94 raise HomeAssistantError
from exp
97 """Fetch new state data for this zone."""
102 for override
in self.
_nobo_nobo.overrides.values():
103 if override[
"target_type"] == nobo.API.OVERRIDE_TARGET_GLOBAL:
114 """Week profile selector for Nobø zones."""
116 _attr_translation_key =
"week_profile"
117 _attr_has_entity_name =
True
118 _attr_should_poll =
False
119 _profiles: dict[int, str] = {}
120 _attr_options: list[str] = []
121 _attr_current_option: str |
None =
None
123 def __init__(self, zone_id: str, hub: nobo) ->
None:
124 """Initialize the week profile selector."""
129 identifiers={(DOMAIN, f
"{hub.hub_serial}:{zone_id}")},
130 name=hub.zones[zone_id][ATTR_NAME],
131 via_device=(DOMAIN, hub.hub_info[ATTR_SERIAL]),
132 suggested_area=hub.zones[zone_id][ATTR_NAME],
136 """Register callback from hub."""
140 """Deregister callback from hub."""
144 """Set week profile."""
145 week_profile_id = [k
for k, v
in self.
_profiles_profiles.items()
if v == option][0]
147 await self.
_nobo_nobo.async_update_zone(
148 self.
_id_id, week_profile_id=week_profile_id
150 except Exception
as exp:
151 raise HomeAssistantError
from exp
154 """Fetch new state data for this zone."""
160 profile[
"week_profile_id"]: profile[
"name"].replace(
"\xa0",
" ")
161 for profile
in self.
_nobo_nobo.week_profiles.values()
165 self.
_nobo_nobo.zones[self.
_id_id][
"week_profile_id"]
None async_added_to_hass(self)
None __init__(self, nobo hub, override_type)
None async_will_remove_from_hass(self)
None async_select_option(self, str option)
None _after_update(self, hub)
None async_added_to_hass(self)
None async_will_remove_from_hass(self)
None __init__(self, str zone_id, nobo hub)
None async_select_option(self, str option)
None _after_update(self, hub)
None async_write_ha_state(self)
None async_setup_entry(HomeAssistant hass, ConfigEntry config_entry, AddEntitiesCallback async_add_entities)