I have a similar task where I want to filter out calculated COP-values for a heat pump that don’t make sense.
# 2024-11-15 Harald
sensor:
- platform: filter
name: "Realistic COP Gree"
entity_id: sensor.gree_cop
filters:
- filter: range
lower_bound: -10
upper_bound: 10
This doesn’t do what I think it should. History data might be unfiltered, but I now get “unavailable”. Is this filter correctly configured?
In the logs it looks like the filter is trying to parse comments i YAML?
2024-11-15 13:58:34.587 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template<template=({# 250, 270, 320, 390, 430, 470, 500 mÂł/h from Gree Pular Service Manual #}
( ( volume * airdensity * ( states('sensor.greeesp_temperature_out') | float - states('sensor.greeesp_temperature_in') | float ) ) * (1000/3600) ) /
2024-11-15 13:58:34.589 ERROR (MainThread) [homeassistant.components.template.template_entity] TemplateError('UndefinedError: dict object has no element None') while processing template 'Template<template=({# 250, 270, 320, 390, 430, 470, 500 mÂł/h from Gree Pular Service Manual #}
( ( volume * airdensity * ( states('sensor.greeesp_temperature_out') | float - states('sensor.greeesp_temperature_in') | float ) ) * (1000/3600) ) /
}}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.gree_cop'
( ( volume * airdensity * ( states('sensor.greeesp_temperature_out') | float - states('sensor.greeesp_temperature_in') | float ) ) * (1000/3600) )
( ( volume * airdensity * ( states('sensor.greeesp_temperature_out') | float - states('sensor.greeesp_temperature_in') | float ) ) * (1000/3600) )
}}) renders=4>' for attribute '_attr_native_value' in entity 'sensor.gree_heatoutput'
edit: the template I’m trying to filter looks like this;
{# 250, 270, 320, 390, 430, 470, 500 mÂł/h from Gree Pular Service Manual #}
{# omitted lowest (silent?) and highest (turbo?) #}
{% set fanspeed = ({"low":"270", "medium low":"320", "medium":"390", "medium high":"430", "high":"470"}) %}
{% set airdensity = 1.17 %}
{% set cop_min = -10 %}
{% set cop_max = 10 %}
{% if state_attr('climate.c6a61428','preset_mode') == "away" %}
{% set volume = fanspeed["low"] |float %}
{% else %}
{% set volume = fanspeed[state_attr('climate.c6a61428','fan_mode')]|float %}
{% endif %}
{# Air volume is {{ volume }} mÂł/h #}
{{
( ( volume * airdensity * ( states('sensor.greeesp_temperature_out') | float - states('sensor.greeesp_temperature_in') | float ) ) * (1000/3600) ) /
( states('sensor.shellygaragetilp_power') | float )
}}
edit²: It looks like it works, but it doesn’t?
editÂł: Oh, it creates a new sensor sensor.realistic_cop_gree and I have to check that instead. OK