Works pretty good, but sometimes one of the sensors shows 0 value (looks like a problem with Netatmo platform) and an average value becomes wrong. I’m trying to sort out zero values, but haven’t found a simple solution yet. I tried
reject jinja2 filter should return a list without zero values, but instead it returns <generator object select_or_reject at ...> and doesn’t work with count filter.
Does anybody familiar with how reject (or select) filter works? Or maybe my issue could be solved even simplier)
its expecting this to be in a for loop, it can’t be used like this. Luckly there’s another filter that will work for you on top of that, the ‘list’ filter. It turns generators into lists.
{{ mylist | reject("==", 0) | list }}
Just make sure you don’t put 0 in quotes because that will be looking for strings. So in your example:
{% set temps = temperatures | reject("==", 0) | list %}
{{ ( temps | sum / temps | count ) | round(1) }}
Is there any documentation on how select and/or reject work? I am trying to find all switches whose object_id starts with a certain string, and return true if any of them are on – basically the functionality of a group.
I’m imagining it’s something like this:
{%- set switches = states.switch
| map(attribute='entity_id')
| select('startswith', 'switch.multipower1_')
| list -%}