jazzyisj/unavailable-entities-sensor

Sensor sensor.unavailable_entities has device class None, state class None

edu24x opened this issue ยท 10 comments

Logger: homeassistant.components.sensor
Source: components/sensor/init.py:605
Integration: Sensor (documentation, issues)
First occurred: 17:36:18 (1 occurrences)
Last logged: 17:36:18

Sensor sensor.unavailable_entities has device class None, state class None and unit entities thus indicating it has a numeric value; however, it has the non-numeric value: (<class 'str'>); Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+template%22

Home Assistant 2023.2.0
Supervisor 2023.01.1
Operating System 9.5
Frontend 20230201.0 - latest

Thanks for the report. A lot of templates are throwing this warning during startup since updating to 2022.2. Not sure how to deal with it yet. I will update when I get it figured out.

I'm also seeing this in the Core logs. Maybe it's related to the same issue?

Template loop detected while processing event: <Event state_changed[L]: entity_id=sensor.unavailable_entities, old_state=<state sensor.unavailable_entities=unavailable; restored=True, icon=mdi:check-circle, friendly_name=Unavailable Entities, supported_features=0, unit_of_measurement=entities @ 2023-02-11T11:09:36.591734-05:00>, new_state=<state sensor.unavailable_entities=; entity_id=[], unit_of_measurement=entities, icon=mdi:check-circle, friendly_name=Unavailable Entities @ 2023-02-11T11:09:36.802754-05:00>>, **skipping template render for Template[{% if state_attr('sensor.unavailable_entities','entity_id') != none %} {{ state_attr('sensor.unavailable_entities','entity_id')|count }} {% endif %}]**

(FYI I have tinkered with the code since installing it; AND I have copied the code, modified, into a second template that monitors my various Pingtrackers. So, it's possible that somehow my 2nd copy is interfering with the original.... although I haven't been able to discern that this is true, nor why.)

@edu24x I posted an updated template that should eliminate the error.

@knwpsk The template loop warning is unrelated. It also does not seem to affect the sensor function. Are you using the most recent version of the sensor template? How often are you seeing it in your logs? It doesn't come up in my logs very often any longer.

Did you see this?

A value for 'ignore_seconds' less than 5 seconds may cause template loop warnings in your home assistant log, particularly when template sensors are reloaded.

@jazzyisj Thank you so much. The warning is fixed and the log is clean.

All the best.

@edu24x I posted an updated template that should eliminate the error.

@knwpsk The template loop warning is unrelated. It also does not seem to affect the sensor function. Are you using the most recent version of the sensor template? How often are you seeing it in your logs? It doesn't come up in my logs very often any longer.

Did you see this?

A value for 'ignore_seconds' less than 5 seconds may cause template loop warnings in your home assistant log, particularly when template sensors are reloaded.

Hey @jazzyisj ,
Thanks for your reply!

I don't see any more loop warnings. I deleted the other template that I had going (a mod'd copy of this one), and I think that did it. I think the two were interfering with each other b/c I was sloppy configuring the second one.

@Bytelink5616 The simplest fix (and what was done in the latest update) is delete the unit of measurement parameter on your unavailable_lights sensor. HA core is getting picky about how you use it which is probably a good thing. Alternatively you can add a state_class: measurement to the template config if you really need the unit_of_measurement parameter for the UI or graphing. Either should fix the warning.