Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106484

Yaml code to filter wrong values

$
0
0

Sorry for late Answer.
As I also get sometimes zero or very high values from the IR Reader of the smart meter I add some code to supress the low values. That is running up to now.

-platform: template
    sensors:
      energy_from_grid:
        friendly_name: "Energy from Grid"
        unique_id: Energy_from_Grid
        device_class: energy
        unit_of_measurement: kWh
        value_template: >
          {% if states('sensor.zaehler_sm_1_8_0') | float < 2000 %}
           {{ states('sensor.energy_from_grid') }}
          {% else %}
           {{ states('sensor.zaehler_sm_1_8_0') | float | multiply(1.0) | round(0) }}
          {% endif %}

This will only transfer new values if bigger than 2000kwh.
But sometimes I also get very big values that I also want to delete.

How to check if the new value is just the same or a little bit bigger than the old one (Energy from Grid)
So if my actual Energy_From Grid value is 2000kwh it should ignore values below 2000 and also ignore values above 2050

I’m not a yaml specialist :frowning:

-platform: template
    sensors:
      energy_from_grid:
        friendly_name: "Energy from Grid"
        unique_id: Energy_from_Grid
        device_class: energy
        unit_of_measurement: kWh
        value_template: >
#Ignore values below the actual energy value
          {% if states('sensor.zaehler_sm_1_8_0') | float < "Energy from Grid" % }
           {{ states('sensor.energy_from_grid') }}

#Ignore values above the actual energy value +50
          {% elseif states('sensor.zaehler_sm_1_8_0') | float > ("Energy from Grid" + 50) % }
           {{ states('sensor.energy_from_grid') }}

          {% else %}
           {{ states('sensor.zaehler_sm_1_8_0') | float | multiply(1.0) | round(0) }}
          {% endif %}

Can someone correct the code for me :wink:

Thank you in advance

Michael

2 posts - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 106484

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>