Skip to content

Commit

Permalink
Merge branch 'release/3.0.0-beta' of github.com:jseidl/hass-magic_are…
Browse files Browse the repository at this point in the history
…as into release/3.0.0-beta
  • Loading branch information
jseidl committed Jan 6, 2022
2 parents fd0fa6c + 12a20ae commit 122b76c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 15 additions & 7 deletions custom_components/magic_areas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,28 @@ async def async_setup(hass, config):
if area.id not in magic_areas_config.keys():
default_config = {f"{area.id}": {}}
config_entry = _DOMAIN_SCHEMA(default_config)[area.id]
_LOGGER.debug(f"Configuration for area {area.name} not found on YAML, creating from default.")
_LOGGER.debug(
f"Configuration for area {area.name} not found on YAML, creating from default."
)
else:
config_entry = magic_areas_config[area.id]
source = SOURCE_IMPORT
_LOGGER.debug(f"Configuration for area {area.name} found on YAML, loading from saved config.")
_LOGGER.debug(
f"Configuration for area {area.name} found on YAML, loading from saved config."
)

if area.normalized_name in reserved_names:
_LOGGER.debug(f"Meta area {area.name} found, setting correct type.")
config_entry.update({CONF_TYPE: AREA_TYPE_META})

extra_opts = {
CONF_NAME: area.name,
CONF_ID: area.id,
}
CONF_NAME: area.name,
CONF_ID: area.id,
}
config_entry.update(extra_opts)
_LOGGER.debug(f"Configuration for area {area.name} updated with extra options: {extra_opts}")
_LOGGER.debug(
f"Configuration for area {area.name} updated with extra options: {extra_opts}"
)

_LOGGER.debug(
f"Creating config flow task for area {area.name} ({area.id}): {config_entry}"
Expand Down Expand Up @@ -148,7 +154,9 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry):
else:
magic_area = MagicMetaArea(hass, area_name, config_entry)

_LOGGER.debug(f"Magic Area {magic_area.name} ({magic_area.id}) created: {magic_area.config}")
_LOGGER.debug(
f"Magic Area {magic_area.name} ({magic_area.id}) created: {magic_area.config}"
)

undo_listener = config_entry.add_update_listener(async_update_options)

Expand Down
2 changes: 2 additions & 0 deletions custom_components/magic_areas/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
if area.has_feature(CONF_FEATURE_LIGHT_GROUPS):
async_add_entities([AreaLightControlSwitch(hass, area)])


class AreaLightControlSwitch(MagicEntity, SwitchEntity, RestoreEntity):
def __init__(self, hass, area):
"""Initialize the area light control switch."""
Expand Down Expand Up @@ -83,6 +84,7 @@ def turn_on(self, **kwargs):
self._state = STATE_ON
self.schedule_update_ha_state()


class AreaPresenceHoldSwitch(MagicEntity, SwitchEntity, RestoreEntity):
def __init__(self, hass, area):
"""Initialize the area presence hold switch."""
Expand Down

0 comments on commit 122b76c

Please sign in to comment.