Automation trigger wants a float - but it is!

I am trying to use a calculation as the “below point” of a numeric state trigger. It is a subtraction of 2 float values, and displays as a float - but I get an error saying a float is required??

The calculation is:

      charging_stop_power_calc:
        friendly_name: "Charging stop calc (W)"
        unit_of_measurement: "W"
        value_template: "{{ (states('input_number.charging_start_power') | float - states('input_number.charging_hysterisis_w') | float) | float }}" 

I used sensor.charging_stop_power_calc as the “below” point of my numeric value trigger.
(I added the extra pipe to float of the resulting subtraction to try and get it to believe it was a float - but as mentioned earlier, it displays with a decimal point anyway.)

Can you please show the automation that gives you the error?
For above: and below: in the numeric state trigger, you can only use input_numbers or hardcoded numbers, not sensors or anything else.

Also, as a random observation, the code you’ve posted looks like it has something else wrong with it based on the colours the forum’s highlighter is using. May be a glitch on the forums, but here’s a picture of how it usually formats code…

Note that the keys are all white and the values are all red?

Now yours…

Top two keys white, bottom two red :man_shrugging:

oh drat - I’ll have to change my plans then. Thanks for clarifying.

It is doing the calculation correctly (not that I can use it now seemingly anyway). I had trouble adding the 3 hyphen characters above and below the code in the post and getting the post to format correctly, so I’m not suprised it came out wrong.

1 Like

You could change it to a template trigger and there you are able to use your sensor.

OK, thanks - I’ll read-up on template triggers.