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

*Another* Template Variable Warning #8769

Closed
OzGav opened this issue Sep 16, 2021 · 8 comments
Closed

*Another* Template Variable Warning #8769

OzGav opened this issue Sep 16, 2021 · 8 comments
Labels
problem Something isn't working

Comments

@OzGav
Copy link
Contributor

OzGav commented Sep 16, 2021

What happened

I am seeing thousands of these warnings:

Logger: homeassistant.helpers.template
Source: helpers/template.py:1485
First occurred: 9:15:11 AM (4774 occurrences)
Last logged: 9:49:31 PM

Template variable warning: 'mappingproxy object' has no attribute 'last_seen' when rendering 'Some Zigbee devices haven't been seen lately... {% for state in states -%} {%- if (state.attributes.last_seen) and not (state.name | regex_search('linkquality|button_fan|update state'))%} {%- if (as_timestamp(now()) - as_timestamp(state.attributes.last_seen) > (60 * 60 * 8) ) %} {{ ((as_timestamp(now()) - as_timestamp(state.attributes.last_seen)) / (3600)) | round(1) }} hours ago for {{ state.name }} {%- endif -%} {%- endif -%} {%- endfor %}'
Template variable warning: 'dict object' has no attribute 'state_button_fan_high' when rendering '{{ value_json.state_button_fan_high }}'
Template variable warning: 'dict object' has no attribute 'state_button_fan_med' when rendering '{{ value_json.state_button_fan_med }}'
Template variable warning: 'dict object' has no attribute 'state_button_fan_low' when rendering '{{ value_json.state_button_fan_low }}'
Template variable warning: 'dict object' has no attribute 'action' when rendering '{{ value_json.action }}'

What did you expect to happen

Not get thousands of warnings? I did create the converter for these light/fan switches so wondering if I missed something in the config? The model of the wall switch is Smart fan light switch (NUE-ZBFLB) which is causing all the state_button_fan warnings.

I think the action warnings are being generated by my MiJia wireless switch (WXKG01LM)

For the first one i am not sure why I am getting an error about not being able to find the last_seen attribute when the first thing that is checked is the existance of that attribute to avoid just this issue?

How to reproduce it (minimal and precise)

Unfortunately I am not sure about this. I don't know what is causing it to happen in the first place. I have reviewed the following similar issues but they don't seem to help
#6987
#7361
https://community.home-assistant.io/t/mqtt-dict-object-has-no-attribute/297330/49

Debug info

Zigbee2MQTT version: 1.18.1-1
Adapter hardware: CC2531
Adapter firmware version: 20190619

@OzGav OzGav added the problem Something isn't working label Sep 16, 2021
@danieledwardgeorgehitchcock
Copy link
Contributor

This might have been broken in this release of Home Assistant:

2021.4

@OzGav
Copy link
Contributor Author

OzGav commented Sep 18, 2021

Maybe so. Either way I am hoping to work out how to resolve this.

@OzGav
Copy link
Contributor Author

OzGav commented Sep 29, 2021

Bump

@mwav3
Copy link

mwav3 commented Oct 1, 2021

The templates in Home assistant need a "default" condition defined now. I set my own custom template to clear the error and posted it here for the Hampton bay fan #8617

I'm not sure how to fix the template sent during mqtt discovery by zigbee2mqtt, otherwise I would submit a pr.

The concern is that starting in 2021.4 this is a warning, but per those release notes, will error in a coming release, possibly as soon as 2021.10

So if this isn't fixed, eventually the template will stop working on some future release.

@OzGav
Copy link
Contributor Author

OzGav commented Oct 3, 2021

Thanks. Let me try your templatre and see if that removes my warnings and then we can see if we can work out what has to happen to get a PR done.

Koenkk added a commit that referenced this issue Oct 9, 2021
Koenkk added a commit that referenced this issue Oct 9, 2021
* Fix more template warnings. #8769

* Update

* Updates
@Koenkk
Copy link
Owner

Koenkk commented Oct 9, 2021

Can you check if this has been fixed in the latest-dev? (edge for hassio)

I see you are still using 1.18.1, probably you are using the old repository; check first point of https://github.com/Koenkk/zigbee2mqtt/releases/tag/1.19.0

Changes will be available in the dev branch in a few hours from now. (https://www.zigbee2mqtt.io/how_tos/how-to-switch-to-dev-branch.html)

@OzGav
Copy link
Contributor Author

OzGav commented Oct 10, 2021

Yes no warnings in the logs and everything seems to be working correctly (I am getting a warning about units changing from V to mV for my Xiaomi buttons but that seems correct and understandable so can sort that out myself)

Thanks @Koenkk

@Koenkk
Copy link
Owner

Koenkk commented Oct 10, 2021

Great!

@Koenkk Koenkk closed this as completed Oct 10, 2021
hacker-cb pushed a commit to hacker-cb/zigbee2mqtt that referenced this issue Nov 5, 2021
* Fix more template warnings. Koenkk#8769

* Update

* Updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants