thomasloven / lovelace-template-entity-row

🔹 Display whatever you want in an entities card row.
MIT License
210 stars 16 forks source link

HA 115 issues with template-entity-row #39

Closed Mariusthvdb closed 3 years ago

Mariusthvdb commented 3 years ago

using a t-e-r setup based on sensors made by a python script (which runs a HA startup) there's huge amounts of errors:

local/lovelace/resources/lovelace-template-entity-row/template-entity-row.js?v=1.1.0:1:2530 TypeError: null is not an object (evaluating 'i.replace')

and

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 306, in async_render_to_info
    render_info._result = self.async_render(variables, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 287, in async_render
    raise TemplateError(err) from err
homeassistant.exceptions.TemplateError: UndefinedError: 'None' has no attribute 'attributes'
2020-09-22 16:09:47 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{states.sensor.birthday_marijn.attributes.type}}: {{states.sensor.birthday_marijn.attributes.original_date}}

repeatedly, in various forms of the templates, for all sensors I have using this particular setup in a card.

config for the card:

title: Celebrations
entities:
  - type: custom:decluttering-card
    template: event_date
    variables:
      - entity: xx

  - type: custom:decluttering-card
    template: event_date
    variables:
      - entity: sensor.birthday_marijn

  - type: custom:decluttering-card
    template: event_date
    variables:
      - entity: xx

and decluttering-card:

card:
  type: custom:template-entity-row
  entity: '[[entity]]'
  state: >
    {{states(config.entity)}} {{state_attr(config.entity, 'unit_of_measurement')}}
  secondary: >
    {{state_attr('[[entity]]','type')}}: {{state_attr('[[entity]]','original_date')}}

used this before:

  secondary: >
    {{states.[[entity]].attributes.type}}: {{states.[[entity]].attributes.original_date}}

which worked fine too, but I thought the states() style would prevent the unknown errors at startup. Unfortunately not.

this setup has worked before, without any issue, up to HA 114.4 but as of HA 115, I've had enormous issues with the templating (or so I believed) I've now been able to establish this t-e-r setup is caught in some kind of loop or race condition at startup, causing the startup process to take very long time (over 8 to 10 minutes) and also causing other integrations to give up.

Simply taking the t-e-r card config out, takes out the startup errors obviously, and speeds-up the startup to just below 4 minutes. Still not what is was on 114.4 but getting close again.

There are various issues with the new templating engine in HA 115, this custom card probably suffers those too, or, causes issues with it.

Please have a look.

I've documented more of this in the community here

Just to be complete: I can simply load the card after startup, and all shows fine, as before. So no errors in the sensors themselves, or the yaml configs of the decluttering card or t-e-r configuration.

seems a timing issue.

thanks

Mariusthvdb commented 3 years ago

this seems to have been solved.

thomasloven commented 3 years ago

Great!