home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.82k stars 30.51k forks source link

Lovelace not loading after 0.81.0 upgrade #17867

Closed CM000n closed 5 years ago

CM000n commented 6 years ago

Home Assistant release with the issue: 0.81.0

Last working Home Assistant release (if known): 0,80.3

Operating environment (Hass.io/Docker/Windows/etc.): Docker on Debian

Component/platform: https://www.home-assistant.io/lovelace/

Description of problem:

Since 0.81 my Lovelace UI isn’t loading anymore. I have some empty views as placeholders in my ui-lavelace.yaml, cause it’s still wip. Maybe that’s the problem? But before 0.81 everything wors fine.

Problem-relevant ui-lavelace.yaml:

resources:
  - url: /local/custom_ui/mini-media-player.js?v=0.8.7
    type: module

name: Zuhause
views:
  - name: Home
    id: home
    icon: mdi:home
    panel: false
    cards:
      - type: entity-filter
        entities:
          - sensor.batterie_heizung_bad
          - sensor.batterie_heizung_buero
        state_filter:
          - "10.0"
          - "9.0"
          - "8.0"
          - "7.0"
          - "6.0"
          - "5.0"
          - "4.0"
          - "3.0"
          - "2.0"
          - "1.0"
          - "0.0"
        card: 
          type: glance
          title: Batteriestände
        show_empty: false
      - type: vertical-stack
        cards:
          - type: entity-filter
            entities:
              - device_tracker.simon_handy
              - device_tracker.lisa_handy
            state_filter:
              - "home"
            card: 
              type: glance
              title: Wer ist daheim?
              show_name: false
              show_state: false
            show_empty: false
          - type: horizontal-stack
            cards:
              - type: sensor
                entity: sensor.e10mue
                name: Spritpreis E10
                height: 75
                line_color: "#3498db"
                accuracy: 100
                hours_to_show: 6
              - type: sensor
                entity: sensor.fahrtzeit_zu_hause__arbeit
                name: Fahrtzeit Arbeit
                height: 75
                line_color: "#3498db"
                accuracy: 100
                hours_to_show: 6
      - type: entities
        entities:
          - entity: sensor.luftdaten_temperature
            name: Außentemperatur
          - entity: sensor.temperatur_wohnzimmer_ecke
            name: Temperatur Wohnzimmer
          - entity: sensor.temperatur_keller
            name: Temperatur Keller
          - entity: climate.heizungbad
            name: Heizung Bad
          - entity: climate.heizungburo
            name: Heizung Büro
        title: Temperatur
        show_header_toggle: false
      - type: entities
        entities:
          - entity: input_select.sonos
          - entity: input_boolean.group_all_sonos
          - entity: media_player.chromecast_wohnzimmer
            name: Chromecast Wohnzimmer
          - entity: media_player.wohnzimmer
            name: Sonos Wohnzimmer
            icon: mdi:music-circle
          - entity: media_player.sonos_schlafzim
            name: Sonos Schlafzimmer
            icon: mdi:music-circle
          - entity: media_player.sonos_bad
            name: Sonos Bad
            icon: mdi:music-circle
        title: Mediaplayer
        show_header_toggle: false
      - type: entity-filter
        entities:
          - sensor.status_spuelmaschine
          - sensor.status_waschmaschine
          - sensor.status_trockner
        state_filter:
          - "Spült"
          - "Trocknet"
          - "Wäscht"
        card: 
          type: entities
          title: Haushaltsgeräte
        show_empty: false
      - type: entity-filter
        entities:
          - switch.kueche
          - switch.wohnzimmer
          - switch.schlafzimmer
          - switch.badezimmer
          - switch.buero
          - switch.flur
          - switch.ankleide
        state_filter:
          - "on"
        card: 
          type: entities
          title: Hauptschalter Räume
        show_empty: false
  - name: Kueche
    id: kueche
    icon: mdi:food-fork-drink
    panel: false
    cards:
  - name: Wohnzimmer
    id: wohnzimmer
    icon: mdi:sofa
    panel: false
    cards:
      - type: custom:mini-media-player
        entity: media_player.chromecast_wohnzimmer
        name: Chromecast Wohnzimmer
        artwork: cover
        hide_power: false
        hide_volume: true
        show_source: true
      - type: custom:mini-media-player
        entity: media_player.wohnzimmer
        name: Sonos Wohnzimmer
        artwork: cover
        hide_power: false
        hide_volume: true
        show_source: true
  - name: Schlafzimmer
    id: schlafzimmer
    icon: mdi:hotel
    panel: false
    cards:
      - type: custom:mini-media-player
        entity: media_player.sonos_schlafzim
        name: Sonos Schlafzimmer
        artwork: cover
        hide_power: false
        hide_volume: true
        show_source: true
  - name: Badezimmer
    id: badezimmer
    icon: mdi:shower
    panel: false
    cards:
      - type: custom:mini-media-player
        entity: media_player.sonos_bad
        name: Sonos Bad
        artwork: cover
        hide_power: false
        hide_volume: true
        show_source: true
  - name: Büro
    id: buero
    icon: mdi:briefcase
    panel: false
    cards:
  - name: Flur
    id: flur
    icon: mdi:floor-plan
    panel: false
    cards:
  - name: Ankleide
    id: ankleide
    icon: mdi:tshirt-v
    panel: false
    cards:
  - name: Wetter
    id: wetter
    icon: mdi:cloud-outline
    panel: true
    cards:
      - type: iframe
        url: https://www.windy.com/49.107/8.714?48.283,8.712,7,m:e0ZagpG
  - name: Systemstatus
    id: systemstatus
    icon: mdi:server-network
    panel: false
    cards:

Traceback Logs:

2018-10-27 09:36:58 ERROR (MainThread) [homeassistant.components.websocket_api.decorators] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/websocket_api/decorators.py", line 16, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/app/homeassistant/components/lovelace/__init__.py", line 271, in websocket_lovelace_config
    load_config, hass.config.path(LOVELACE_CONFIG_FILE))
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/lovelace/__init__.py", line 145, in load_config
    for card in view.get('cards', []):
TypeError: 'NoneType' object is not iterable
2018-10-27 09:37:11 ERROR (MainThread) [homeassistant.components.websocket_api.decorators] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/websocket_api/decorators.py", line 16, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/app/homeassistant/components/lovelace/__init__.py", line 271, in websocket_lovelace_config
    load_config, hass.config.path(LOVELACE_CONFIG_FILE))
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/lovelace/__init__.py", line 145, in load_config
    for card in view.get('cards', []):
TypeError: 'NoneType' object is not iterable
2018-10-27 09:37:39 ERROR (MainThread) [homeassistant.components.websocket_api.decorators] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/websocket_api/decorators.py", line 16, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/app/homeassistant/components/lovelace/__init__.py", line 271, in websocket_lovelace_config
    load_config, hass.config.path(LOVELACE_CONFIG_FILE))
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/lovelace/__init__.py", line 145, in load_config
    for card in view.get('cards', []):
TypeError: 'NoneType' object is not iterable
2018-10-27 09:38:51 ERROR (MainThread) [homeassistant.components.websocket_api.decorators] Unexpected exception
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/websocket_api/decorators.py", line 16, in _handle_async_response
    await func(hass, connection, msg)
  File "/usr/src/app/homeassistant/components/lovelace/__init__.py", line 271, in websocket_lovelace_config
    load_config, hass.config.path(LOVELACE_CONFIG_FILE))
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/lovelace/__init__.py", line 145, in load_config
    for card in view.get('cards', []):
TypeError: 'NoneType' object is not iterable
cgarwood commented 6 years ago

Looks like your assessment is correct. You may be able to just remove the cards: lines and get it to load

cheynespc commented 5 years ago

im having the same issue

G8YTZ commented 5 years ago

Similar issue here 81.5. I've found if I cut the Lovelace yaml file down to just one or two pages it works ok, the issue seems to be related to multi-page files. Attached is my file, just with security related items deleted and replace with xxxxxxxxxxxxxx The heating and lighting devices are KNX ui-lovelace.txt

jimpastos commented 5 years ago

Same issue here. My ui-lovelace has cards: !include that does not work any more. Dumping everything into the main ui-lovelace.yaml works

CM000n commented 5 years ago

Replacing the card lines from the empty views fixed this completely for me. Thank you all!

G8YTZ commented 5 years ago

Hi, could you explain what "Replacing the card lines from the empty views" Apologies for being rather thick! :-) A worked example would be most appreciated.

CM000n commented 5 years ago

Hi @G8YTZ

it's pretty simple. I just deleted the cards entry from empty vies like this

  - name: Systemstatus
    id: systemstatus
    icon: mdi:server-network
    panel: false
    cards:
G8YTZ commented 5 years ago

You mean the statement cards: like my above example?

CM000n commented 5 years ago

yes

phrfpeixoto commented 4 years ago

HA Version: 0.108.0

I'm also having the same issue with the !include statement. It causes lovelace to crash during startup:

2020-05-02 12:10:11 ERROR (MainThread) [homeassistant.setup] Error during setup of component lovelace
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 171, in _async_setup_component
    hass, processed_config
  File "/usr/src/homeassistant/homeassistant/components/lovelace/__init__.py", line 97, in async_setup
    resource_collection = await create_yaml_resource_col(hass, yaml_resources)
  File "/usr/src/homeassistant/homeassistant/components/lovelace/__init__.py", line 222, in create_yaml_resource_col
    ll_conf = await default_config.async_load(False)
  File "/usr/src/homeassistant/homeassistant/components/lovelace/dashboard.py", line 186, in async_load
    self._load_config, force
  File "/usr/local/lib/python3.7/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 204, in _load_config
    config = load_yaml(self.path)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 61, in load_yaml
    return yaml.load(conf_file, Loader=SafeLineLoader) or OrderedDict()
  File "/usr/local/lib/python3.7/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 51, in get_single_data
    return self.construct_document(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 55, in construct_document
    data = self.construct_object(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 195, in _ordered_dict
    nodes = loader.construct_pairs(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 155, in construct_pairs
    value = self.construct_object(value_node, deep=deep)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 172, in _include_dir_list_yaml
    for f in _find_files(loc, "*.yaml")
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 173, in <listcomp>
    if os.path.basename(f) != SECRET_YAML
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 61, in load_yaml
    return yaml.load(conf_file, Loader=SafeLineLoader) or OrderedDict()
  File "/usr/local/lib/python3.7/site-packages/yaml/__init__.py", line 114, in load
    return loader.get_single_data()
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 51, in get_single_data
    return self.construct_document(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 55, in construct_document
    data = self.construct_object(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 195, in _ordered_dict
    nodes = loader.construct_pairs(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 155, in construct_pairs
    value = self.construct_object(value_node, deep=deep)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 226, in _construct_seq
    (obj,) = loader.construct_yaml_seq(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 408, in construct_yaml_seq
    data.extend(self.construct_sequence(node))
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 130, in construct_sequence
    for child in node.value]
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 130, in <listcomp>
    for child in node.value]
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 195, in _ordered_dict
    nodes = loader.construct_pairs(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 155, in construct_pairs
    value = self.construct_object(value_node, deep=deep)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 226, in _construct_seq
    (obj,) = loader.construct_yaml_seq(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 408, in construct_yaml_seq
    data.extend(self.construct_sequence(node))
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 130, in construct_sequence
    for child in node.value]
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 130, in <listcomp>
    for child in node.value]
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 195, in _ordered_dict
    nodes = loader.construct_pairs(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 155, in construct_pairs
    value = self.construct_object(value_node, deep=deep)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 226, in _construct_seq
    (obj,) = loader.construct_yaml_seq(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 408, in construct_yaml_seq
    data.extend(self.construct_sequence(node))
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 130, in construct_sequence
    for child in node.value]
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 130, in <listcomp>
    for child in node.value]
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 195, in _ordered_dict
    nodes = loader.construct_pairs(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 155, in construct_pairs
    value = self.construct_object(value_node, deep=deep)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 226, in _construct_seq
    (obj,) = loader.construct_yaml_seq(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 408, in construct_yaml_seq
    data.extend(self.construct_sequence(node))
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 130, in construct_sequence
    for child in node.value]
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 130, in <listcomp>
    for child in node.value]
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 195, in _ordered_dict
    nodes = loader.construct_pairs(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 155, in construct_pairs
    value = self.construct_object(value_node, deep=deep)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 226, in _construct_seq
    (obj,) = loader.construct_yaml_seq(node)
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 408, in construct_yaml_seq
    data.extend(self.construct_sequence(node))
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 130, in construct_sequence
    for child in node.value]
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 130, in <listcomp>
    for child in node.value]
  File "/usr/local/lib/python3.7/site-packages/yaml/constructor.py", line 100, in construct_object
    data = constructor(self, node)
  File "/usr/src/homeassistant/homeassistant/util/yaml/loader.py", line 114, in _include_yaml
    fname = os.path.join(os.path.dirname(loader.name), node.value)
  File "/usr/local/lib/python3.7/posixpath.py", line 94, in join
    genericpath._check_arg_types('join', a, *p)
  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'

Debugging, I've narrowed it down to this yaml file below, due to these !include statements

#lovelace-gen
title: Sistema
icon: mdi:server
cards:
  - type: custom:layout-card
    layout: horizontal
    cards:
      - type: custom:layout-card
        layout: vertical
        style: !include ../styles/card.yaml
        cards:
          - type: markdown
            content: Sistema e Monitoria
            style: !include ../styles/title.yaml
          - type: custom:vertical-stack-in-card
            cards: 
              - type: horizontal-stack
                cards:
                  - !include
                    - ../templates/graphs_embeded.yaml
                    - entity: sensor.processor_use
                      name: CPU
                      hours_to_show: 12
                      points_per_hour: 4
                      line_color: var(--custom_graph_color_1)
                  - !include
                      - ../templates/graphs_embeded.yaml
                      - entity: sensor.memory_use_percent
                        name: Memória
                        hours_to_show: 12
                        points_per_hour: 4
                        line_color: var(--custom_graph_color_2)
                  - !include
                      - ../templates/graphs_embeded.yaml
                      - entity: sensor.disk_use_percent
                        name: I/O
                        hours_to_show: 12
                        points_per_hour: 4
                        line_color: var(--custom_graph_color_3)
              - type: entities
                style: !include ../styles/entities_embeded.yaml
                entities:
                  - sensor.cpu_temp
                  - sensor.database_size
                  - sensor.hass_io_uptime_pretty
      - type: custom:layout-card
        layout: vertical
        style: !include ../styles/card.yaml
        cards:
          - type: markdown
            content: Rede e Internet
            style: !include ../styles/title.yaml
          - type: custom:vertical-stack-in-card
            cards:
              - type: entities
                title: Google Wifi
                show_header_toggle: false
                entities:
                  - entity: sensor.google_wifi_status
                  - entity: sensor.google_wifi_local_ip
                  - entity: sensor.google_wifi_uptime
                  - entity: sensor.google_wifi_last_restart
              - type: entities
                title: SpeedTest
                show_header_toggle: false
                entities:
                  - entity: sensor.speedtest_download
                  - entity: sensor.speedtest_upload
                  - entity: sensor.speedtest_ping

@CM000n Do you also see invalid YAML here?

@G8YTZ

I've found if I cut the Lovelace yaml file down to just one or two pages it works ok. the issue seems to be related to multi-page files

Could you please clarify what you mean here? Can't we split the configuration into several files anymore?

@jimpastos Have you managed to solve the issue with !inlcude?

phrfpeixoto commented 4 years ago

I have a strong indication that this is a bug because the issue only happens on startup.

If I comment this whole file out, let HA startup, and then add it back, lovelace can load it properly.

phrfpeixoto commented 4 years ago

I managed to solve the issue after the update to 109.0 and moving the components section from lovelace-ui.yaml to the main configuration.yaml file

Thanks!