Exclusion of zero value when reading Modbus

Hello
How to exclude reading zero value at Modbus in configuration.yaml (energy reading from meter sometimes gives zero value, which disturbs energy panel values). From what I found out HA has problems with the Modbus standard.

modbus:
  - name: "iSMA"
    type: tcp
    host: 192.168.3.123
    port: 502 
    sensors:
      - name: "iSMA Energia pobrana"
        device_class: energy
        unit_of_measurement: kWh
        slave: 1
        address: 1020
        input_type: holding
        count: 2
        swap: word
        data_type: float32
        precision: 2
        scan_interval: 60
      - name: "iSMA Energia oddana"
        device_class: energy
        unit_of_measurement: kWh
        slave: 1
        address: 1022
        input_type: holding
        count: 2
        swap: word
        data_type: float32
        precision: 2 
        scan_interval: 60

Use templates or filters after modbus sensors

I have it, but how do I make it to attach for value zero the previous reading? With this condition I have at zero the value of the entity undefined

template:
  - sensor:

      - name: "Energia pobrana"
        device_class: energy
        unit_of_measurement: kWh
        state: >
          {% if states('sensor.isma_energia_pobrana') | float > 0 %} {{ states('sensor.isma_energia_pobrana') | float }}
          {%- endif %}
      - name: "Energia oddana"
        device_class: energy
        unit_of_measurement: kWh
        state: >
          {% if states('sensor.isma_energia_oddana') | float > 0 %} {{ states('sensor.isma_energia_oddana') | float }}
          {%- endif %}
      - name: "new sensor"
        state: >-
          {% set x = states('sensor.modbus')|float(0) %}
          {% if x > 0 %}
            {{ x }}
          {% else %}
            {{ states('sensor.new_sensor') }}
          {% endif %}

Thank you for the hint.
And how to make that a change of ±10 value is rejected