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

Unknown error when using this with auto-entities #32

Closed
ghost opened this issue Aug 24, 2020 · 2 comments
Closed

Unknown error when using this with auto-entities #32

ghost opened this issue Aug 24, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 24, 2020

I have a really strange issue. I have a new HA install on a Raspberry Pi 4.
I've added the latest version of these through HACS:

Configuration (anniversaries):

anniversaries:
  sensors:
  - name: Person A
    date: '1980-12-01'
    icon_today: mdi:party-popper

I then try to filter all of the entities and create the card.
My goal is to make a list of birthdays that show a sorted list with the age and birthday.

type: custom:auto-entities
card:
  type: entities
  title: Birthdays
  show_header_toggle: false
filter:
  include:
    - entity_id: sensor.anniversary*
      state: < 120
      sort:
        method: state
        numeric: true

That gives you something like this:
image

Then I wanted to use "lovelace-template-entity-row" to override "29 days" to "Today/Tommorrow/29 days" depending on the number of days left and also add a secondary_info saying for example: "35 Years old (01.12.1980)".

However whenever I modify the code to something like this:

type: custom:auto-entities
card:
  type: entities
  title: Birthdays
  show_header_toggle: false
filter:
  include:
    - entity_id: sensor.anniversary*
      state: < 120
      options:
        type: custom:template-entity-row
        secondary: >-
          {% if is_state(entity, '0') %}
            {{ state_attr(entity, 'current_years') }} Years
          {% else %}
            {{ state_attr(entity, 'years_at_next_anniversary') }} Years
          {% endif %}
            ({{ as_timestamp(state_attr(entity, 'date')) | timestamp_custom('%d.%m.%Y') }})
      sort:
        method: state
        numeric: true

and hit "Refresh" in HA I get "Unknown error / Reload UI". Hitting F5 brings the cached and working page back...
Any ideas on why I keep getting this error?

@ghost
Copy link
Author

ghost commented Aug 24, 2020

I'm mistaken. This is a issue with lovelace_gen

Here's a working example. Works in ui-lovelace.yaml, but once moved into its own yaml file it throws a "Unknown error".
Doesn't matter what I do or use, once I add the custom:template-entity-row state or secondary code it crashes.

- type: custom:auto-entities
            show_empty: true
            card:
              title: Birthdays
              type: entities
              show_header_toggle: false
            sort:
              method: state
              numeric: true
            filter:
              include:
                - entity_id: "sensor.anniversary_*"
                  state: < 120
                  options:
                    type: custom:template-entity-row
                    state: >-
                      {% if is_state(config.entity, '0') %}
                        Today
                      {% elif is_state(config.entity, '1') %}
                        Tomorrow
                      {% else %}
                        {{ states(config.entity) }} Days
                      {% endif %}
                    secondary: >-
                      {% if is_state(config.entity, '0') %}
                        {{ state_attr(config.entity, 'current_years') }} Years
                      {% else %}
                        {{ state_attr(config.entity, 'years_at_next_anniversary') }} Years
                      {% endif %}
                        ({{ as_timestamp(state_attr(config.entity, 'date')) | timestamp_custom('%d.%m.%Y') }})

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

1 participant