thomasloven / hass-lovelace_gen

🔹 Improve the lovelace yaml parser for Home Assistant
MIT License
221 stars 22 forks source link

HA 2021.4 TypeError: 'Secrets' object is not a mapping #28

Closed dougmaitelli closed 3 years ago

dougmaitelli commented 3 years ago

After upgrading HA to 2021.4 lovelace_gen breaks due to:

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/lovelace_gen/__init__.py:32
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 12:35:32 PM (10 occurrences)
Last logged: 12:42:00 PM

[139888434880464] Error handling message: Unknown error
[139888584707760] Error handling message: Unknown error
[139888495275312] Error handling message: Unknown error
[139888435017280] Error handling message: Unknown error
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 18, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/homeassistant/homeassistant/components/lovelace/websocket.py", line 30, in send_with_error_handling
    result = await func(hass, connection, msg, config)
  File "/usr/src/homeassistant/homeassistant/components/lovelace/websocket.py", line 72, in websocket_lovelace_config
    return await config.async_load(msg["force"])
  File "/usr/src/homeassistant/homeassistant/components/lovelace/dashboard.py", line 188, in async_load
    is_updated, config = await self.hass.async_add_executor_job(
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/lovelace/dashboard.py", line 207, in _load_config
    config = load_yaml(self.path, Secrets(Path(self.hass.config.config_dir)))
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 112, in load_yaml
    return parse_yaml(conf_file, secrets)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 124, in parse_yaml
    yaml.load(content, Loader=lambda stream: SafeLineLoader(stream, secrets))
  File "/usr/local/lib/python3.8/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 51, in get_single_data
    return self.construct_document(node)
  File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 55, in construct_document
    data = self.construct_object(node)
  File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 254, in _ordered_dict
    nodes = loader.construct_pairs(node)
  File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 155, in construct_pairs
    value = self.construct_object(value_node, deep=deep)
  File "/usr/local/lib/python3.8/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 229, in _include_dir_list_yaml
    return [
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 230, in <listcomp>
    load_yaml(f, loader.secrets)
  File "/config/custom_components/lovelace_gen/__init__.py", line 32, in load_yaml
    stream = io.StringIO(jinja.get_template(fname).render({**args, "_global": llgen_config}))
TypeError: 'Secrets' object is not a mapping
theone11 commented 3 years ago

I had the same problem. UI not being generated. image

I solved it by updating to the latest files - copied over init.py and manifest.json

dougmaitelli commented 3 years ago

My lovelace_gen is installed over HACS. But I don't see pending updates for it, any idea on how to trigger that?

dougmaitelli commented 3 years ago

I guess the only problem is that this fix which is marked as 0.1.1 in the manifest does not have a github release associated to it. Forcing HACS to use the master branch fixed the problem for me.

thomasloven commented 3 years ago

New release has been published.