Translating power readings into states

Hello dear people.

@Didgeridrew helped me figure out how to set up a template senor to translate the power measurements of my pellet heating into status description.

      - name: "Pellet heating status"
        availability: "{{ has_value('sensor.shellypro4pm_08f9e0e9ed64_switch_2_power') }}"
        state: >-
          {% set power = states('sensor.shellypro4pm_08f9e0e9ed64_switch_2_power') | float(0) %} 
          {% if  power < 3 %}
            off
          {% elif power < 20 %}
            stand by
          {% elif power < 140 %}
            warmup / heat dispersion
          {% elif power < 270 %}
            heating
          {% elif power > 270 %}
            ignition
          {% endif %}

Now that this sensor is working I tried fine-tuning it but realize its not quite as simple, since there are small spikes that throw the reading off and since some other automations depend on the sensor state this is a problem. this could probably be fixed by having the sensor adjust only if the reading has been in a certain state for e.g. one minute - I just don’t know how to do this.

Also the “heat dispersion” is within the power range of the “heating” phase, so I cant really distinguish between the two.

In the picture is the power reading of a (short) burn cycle of the pellet heating, with makings on to what it should translate to. Has anyone an idea on how to make this happen? Since the burn sicle always the same (Ignition/Warmup/Heating/Heat Dissipation/Standby) there could also be some sort of sequencial solution, that goes from oen state to enother by some trigger in the pattern?

Please bear with me, I’m a total programming-noob.
Thanks in advance for any input!

You may want to play around with some of the option available in the Filter integration to see if you can tame the spikes.

You’ll likely need to move to an automation instead of relying solely on the state. With an automation you have the option of using Wait for Trigger actions so you can follow the pattern’s sequence.

You may want to check out the following Blueprint: