I have a Zigbee device that returns two entites:
sensor.hovedmaler_instantaneous_demand
sensor.hovedmaler_summation_delivered
Both devices can return invalid readings and as this is my main grid logger this means I have no working history of readings. For instant readings this happens like every 5 minutes and for summation this happens like 3-5 times daily).
So I thought, I’ll create a template sensor that takes the original readings and if they are the invalid readings, they will get ignored. These are the two filtering sensors I created:
template:
- sensor:
- name: "Hovedmåler Summation delivered (filtreret)"
unique_id: "hovedmaler_summation_delivered_filtered"
unit_of_measurement: "kWh"
device_class: "energy"
state_class: "total_increasing"
state: "{{ states('sensor.hovedmaler_summation_delivered') }}"
availability: "{{ states('sensor.hovedmaler_summation_delivered') != '281474976710.655' and is_state('sensor.hovedmaler_summation_delivered', 'unknown') == false }}"
- name: "Hovedmåler Instantaneous demand (filtreret)"
unique_id: "hovedmaler_instantaneous_demand_filtered"
unit_of_measurement: "W"
device_class: "power"
state_class: "measurement"
state: "{{ states('sensor.hovedmaler_instantaneous_demand') }}"
availability: "{{ states('sensor.hovedmaler_instantaneous_demand') != '-8388608' and is_state('sensor.hovedmaler_instantaneous_demand', 'unknown') == false }}"
If we just focus on the instant reading first (the invalid reading occurs more often and has a smaller value), the value -8388608 must be ignored. But what I have created does not make the value be ignored.
Any idea how I can solve this problem?