Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lovelace_gen cannot parse !include in view #11

Open
ALERTua opened this issue Mar 16, 2020 · 5 comments
Open

lovelace_gen cannot parse !include in view #11

ALERTua opened this issue Mar 16, 2020 · 5 comments

Comments

@ALERTua
Copy link

ALERTua commented Mar 16, 2020

  • Latest Dev Hassos 4.4 @ Windows 10 via Virtualbox
  • Latest Supervisor 209
  • Latest Dev Core 0.107.0b5
  • Latest HACS 0.23.2
  • Latest lovelace_gen Add support for directory traversal #6 installed via HACS
    Everything was working, but suddenly lovelace_gen forgot how to parse !include in views.
# lovelace_gen
title: test
path: test
panel: false
cards:
  - !include
    - /config/lovelace/templates/minigraph.yaml
    - entities:
      - sensor.disk_use_percent

minigraph.yaml:

# lovelace_gen
# https://github.com/kalkih/mini-graph-card
type: custom:mini-graph-card
entities: {{ entities|default(['sensor.processor_use']) }}

results in

  File "/usr/local/lib/python3.7/genericpath.py", line 153, in _check_arg_types
    (funcname, s.__class__.__name__)) from None
TypeError: join() argument must be str or bytes, not 'list'

and Hassio goes into the safe mode.
As soon as I comment out the usage of the view that contains at least one !include - everything returns to normal after HA restart.

@ALERTua ALERTua changed the title lovelace_gen cannot parse !inclue in view lovelace_gen cannot parse !include in view Mar 16, 2020
@DickSwart
Copy link

Think this issue is with the custom:mini-graph-card and lovelace_gen. But I don't have errors loading other cards..

@nielsfaber
Copy link

@thomasloven
Could you take a look at this issue?
I'm having the same problem, see also my forum post.

It is very easy to reproduce.
I created a new Docker container with fresh HA installation (v0.113.3), default config, only added the custom_component/lovelace_gen.

ui-lovelace.yaml

views:
  - title: Example
    cards:
      - !include
        - my_markdown_card.yaml
        - text: Some example text

my_markdown_card.yaml

# lovelace_gen
type: markdown
content: '{{ text }}'

The result is as I would expect:
Before restart

But after restart HA:
After restart

Loggings point to:

homeassistant_debug    |   File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 111, in _include_yaml
homeassistant_debug    |     fname = os.path.join(os.path.dirname(loader.name), node.value)
homeassistant_debug    |   File "/usr/local/lib/python3.8/posixpath.py", line 90, in join
homeassistant_debug    |     genericpath._check_arg_types('join', a, *p)
homeassistant_debug    |   File "/usr/local/lib/python3.8/genericpath.py", line 152, in _check_arg_types
homeassistant_debug    |     raise TypeError(f'{funcname}() argument must be str, bytes, or '
homeassistant_debug    | TypeError: join() argument must be str, bytes, or os.PathLike object, not 'list'

Full log file: logfile.txt

It seems to have to do with the order in which HA loads its components.
The Lovelace config apparently is parsed before lovelace_gen is loaded, so it does not know how to parse an !include with extra parameters.
My current workaround (also mentioned by others) is to comment out the views: section before restarting HA, then uncommenting after HA is completely started, and then refreshing.

I am very surprised that plenty people don't experience this problem, makes me wonder if I missed something.
I hope you could take a look at it, maybe try out this scenario in your own config.

@thomasloven
Copy link
Owner

Skärmavbild 2020-08-12 kl  08 19 23

@nielsfaber
Copy link

Hi Thomas.
As mentioned before, this is literally the complete ui-lovelace.yaml I am using:

views:
  - title: Example
    cards:
      - !include
        - my_markdown_card.yaml
        - text: Some example text

So it must be something else...

@thomasloven
Copy link
Owner

And the multi-argument !include is a lovelace_gen feature, and thus will not work there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants