hass-lovelace_gen icon indicating copy to clipboard operation
hass-lovelace_gen copied to clipboard

lovelace_gen cannot parse !include in view

Open ALERTua opened this issue 5 years ago • 5 comments
trafficstars

  • 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 #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 avatar Mar 16 '20 19:03 ALERTua

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

DickSwart avatar May 30 '20 08:05 DickSwart

@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.

nielsfaber avatar Aug 12 '20 05:08 nielsfaber

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

thomasloven avatar Aug 12 '20 06:08 thomasloven

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...

nielsfaber avatar Aug 12 '20 06:08 nielsfaber

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

thomasloven avatar Aug 12 '20 09:08 thomasloven