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

template warnings under 2021.4.x #32

Open
jonwaland opened this issue Apr 9, 2021 · 5 comments
Open

template warnings under 2021.4.x #32

jonwaland opened this issue Apr 9, 2021 · 5 comments

Comments

@jonwaland
Copy link

2021-04-09 13:17:00 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'mappingproxy object' has no attribute 'icon' when rendering '{%- for item in states.sensor if (.....

Warning is created in the update_battery_status_group_members automation

@tfili
Copy link

tfili commented Apr 12, 2021

@jonwaland That fix seems like it wouldn't be what you want. That fix says if icon isn't defined then it will never add the entity. Something like this would probably be better:

              {%- for item in states.sensor if (
                not is_state_attr(item.entity_id, 'hidden', true)
                and (
                  is_state_attr(item.entity_id, 'device_class', 'battery')
                  or (item.attributes.icon is defined and 'battery' in item.attributes.icon | lower)
                  or (item.entity_id | lower).endswith('_bat')
                  or (item.name | lower).endswith('_bat')
                  ) or (
                    (
                      'battery' in item.entity_id | lower
                      or 'battery' in item.name | lower
                    ) and (
                      item.attributes.icon is not defined
                    ) and (
                      not is_state_attr(item.entity_id, 'battery_alert_disabled', true)
                    ) and (
                      not is_state_attr(item.entity_id, 'restored', true)
                    )
                  )
                )
              -%}
                {{ item.entity_id }}{% if not loop.last %}, {% endif %}
              {%- endfor -%}

@jonwaland
Copy link
Author

yup - my mistake - I meant it to be a qualifier for the check - but put it outside. thanks.

So how to get this added to the actual package for others?

@tfili
Copy link

tfili commented Apr 13, 2021

It's up to @notoriousbdg. Do you want a PR or do you want to just make the fix.

@tingox
Copy link

tingox commented Nov 27, 2021

pull request #33 fixes the warnings for me in Home Assistant 2021.11.3 - thanks!

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

3 participants