Hi @ all and jazzyisj, I use your sensor definitions and they work great. Up to now:
For another reason I created two new entities:
sensor.statistics_entities_groups
sensor.statistics_entities_groups_percentage
When reloading groups (not template sensors which the above two are based on) and therefore my/your problems_any
and problems_any_ignored
sensors, this leads to the following two things:
- Your template sensor
sensor.problems_any
detects my two above listed sensors as “problematic” (unknown, unavailable or whatever) - just for a minute after the sensor is recreated
- The following error is stored in HA log:
Logger: homeassistant.components.template.template_entity
Source: components/template/template_entity.py:140
Integration: Template (documentation, issues)
First occurred: 23:29:12 (8 occurrences)
Last logged: 23:46:36
TemplateError('TypeError: argument of type 'NoneType' is not iterable') while processing template 'Template("{{ states|selectattr('state','in',['unavailable','unknown','none'])|rejectattr('domain','eq','group') |rejectattr('entity_id','in',state_attr('group.problems_any_ignored','entity_id'))|list|count }}")' for attribute '_attr_native_value' in entity 'sensor.problems_any'
TemplateError('TypeError: argument of type 'NoneType' is not iterable') while processing template 'Template("{{ states|selectattr('state','in',['unavailable','unknown','none'])|rejectattr('domain','eq','group') |rejectattr('entity_id','in',state_attr('group.problems_any_ignored','entity_id'))|map(attribute='entity_id')|list }}")' for attribute 'Entitäten' in entity 'sensor.problems_any'
I have no idea why and how to fix that.
Is it because your template sensors want to do something because my entities are named “sensor.*group*” (not “group.something”!)?
Maybe I could simply put those two sensors on the ignore list, but it feels like this is some error in the template sensor definition so I wanted to inform you. Maybe you have an idea.
Full disclosure: this is my template sensor definition which I never changed (it simply worked):
- platform: template
sensors:
problems_any:
friendly_name: Problematische Entitäten
unit_of_measurement: Entitäten
icon_template: "{{ 'mdi:check-circle' if is_state('sensor.problems_any','0') else 'mdi:alert' }}"
value_template: >
{{ states|selectattr('state','in',['unavailable','unknown','none'])|rejectattr('domain','eq','group')
|rejectattr('entity_id','in',state_attr('group.problems_any_ignored','entity_id'))|list|count }}
attribute_templates:
Entitäten: >
{{ states|selectattr('state','in',['unavailable','unknown','none'])|rejectattr('domain','eq','group')
|rejectattr('entity_id','in',state_attr('group.problems_any_ignored','entity_id'))|map(attribute='entity_id')|list }}