False positives on trigger... numeric state below: 1

HI,

have this:

  - alias: Espresso bijvullen
    id: 'Espresso bijvullen'
    initial_state: 'on'
    trigger:
      platform: numeric_state
      entity_id: sensor.espresso_keuken_actueel
      above: 0
      below: 1
      for:
       seconds: 45

which triggers when power is low (because the waterlevel is low) and notifies me of that. Worked just fine. As of late, this seems to be triggering falsely, if and when the power is on 1.4 watts, which is the value the machine is on when boiler is not heating, but all is well.

why would the below: 1 still trigger when the state value is 1,4? Ive checked and the value hasn’t reached the below 1 in the history of the sensor, and still it triggered just now.

maybe I can change the trigger to a template:

  platform: template
  value_template: >
    {{ 0 < states('sensor.espresso_keuken_actueel')|float < 1 and
      (now() - trigger.to_state.state | default(0) ).total_seconds() > 45 }} 

still, the original numeric trigger worked fine, and should still be correct?

btw, before you ask: the above: 0 is needed for when 0 the machine is Off. SO 3 possible states:
0: machine = Off
between 0 and 1: machine is On but out of water and boiler is not used
above 1 (or 1,4 really but that is of no consequence) up to 1269,5 : Machine is in use and boiler is switching on and off.

Hope you can have a look and see what is wrong? Would I maybe only need the below: 1 ?

have a template sensor based on the same ‘sensor.espresso_keuken_actueel’ like this:

sensors:
  espresso_water_level:
    unit_of_measurement: Espresso
    friendly_name_template: >
      {% if states('sensor.espresso_keuken_actueel')|float == 0 %}
        Off
      {% elif 0 < states('sensor.espresso_keuken_actueel')|float < 1 %}
        'Needs refill'
      {% else %}
        Enjoy!
      {% endif %}
    value_template: >
      {% if states('sensor.espresso_keuken_actueel')|float == 0 %}
        Off
      {% elif 0 < states('sensor.espresso_keuken_actueel')|float < 1 %}
        'Needs refill'
      {% else %}
        Enjoy!
      {% endif %}
    entity_picture_template: >
      {% if states('sensor.espresso_keuken_actueel')|float == 0  %}
        /local/buttons/button_power_off.png
      {% elif 0 < states('sensor.espresso_keuken_actueel')|float < 1 %}
        /local/various/watertap.png
      {% else %}
        /local/activities/opstaan.png
      {% endif %}

26 48 17

btw why should it be |float == 0 instead of |int == 0 in the first line of each template? |int == 0 is true if value == 0.7 (in dev-template) but the template_sensor doesn’t evaluate it correctly somehow. Had |int before and it worked as desired, but now had to change to |float.

this works fine too, so cool to be able to reference the template sensors value itself in the template sensors friendly name and icon templates:

  espresso_water_level:
    unit_of_measurement: Espresso
    friendly_name_template: >
      {{states('sensor.espresso_water_level')}}
    value_template: >
      {% if states('sensor.espresso_keuken_actueel')|float == 0 %}
        Off
      {% elif 0 < states('sensor.espresso_keuken_actueel')|float < 1 %}
        Needs refill
      {% else %}
        Enjoy!
      {% endif %}
    entity_picture_template: >
      {% if is_state('sensor.espresso_water_level','Off') %} local/buttons/button_power_off.png
      {% elif is_state('sensor.espresso_water_level','Needs refill') %} /local/various/watertap.png
      {% else %} /local/activities/opstaan.png
      {% endif %}