Skip to content

Commit 2c93963

Browse files
committed
Properly support ResourceYAMLCollection
1 parent 10616f9 commit 2c93963

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

custom_components/lock_code_manager/__init__.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,24 @@ async def async_setup(hass: HomeAssistant, config: Config) -> bool:
9191
if data[CONF_URL] == STRATEGY_PATH
9292
)
9393
except StopIteration:
94-
# Register strategy module
95-
data = await resources.async_create_item(
96-
{CONF_RESOURCE_TYPE_WS: "module", CONF_URL: STRATEGY_PATH}
97-
)
98-
_LOGGER.debug("Registered strategy module (resource ID %s)", data[CONF_ID])
99-
hass.data[DOMAIN]["resources"] = True
94+
if isinstance(resources, ResourceYAMLCollection):
95+
_LOGGER.warning(
96+
"Strategy module can't automatically be registered because this "
97+
"Home Assistant instance is running in YAML mode for resources. "
98+
"Please add a new entry in the list under the resources key in "
99+
"the lovelace section of your config as follows:\n - url: %s"
100+
"\n type: module",
101+
STRATEGY_PATH,
102+
)
103+
else:
104+
# Register strategy module
105+
data = await resources.async_create_item(
106+
{CONF_RESOURCE_TYPE_WS: "module", CONF_URL: STRATEGY_PATH}
107+
)
108+
_LOGGER.debug(
109+
"Registered strategy module (resource ID %s)", data[CONF_ID]
110+
)
111+
hass.data[DOMAIN]["resources"] = True
100112
else:
101113
_LOGGER.debug(
102114
"Strategy module already registered with resource ID %s", res_id

0 commit comments

Comments
 (0)