Need a quick breakdown of meanings of float, int, and how to use them

So instead of asking someone to fix my automation I like a quick breakdown of the functons please if some one would be so kind.

So I have a numeric value 2000.20 its 4 digets and 2 afther the .

{{ trigger.from_state.state|float(0) < trigger.to_state.state|float(0) }}

What does float convert it to ? a single digit or 4 or the whole value ?
Same exact question for int.

can < = > also be used to say how much increase afther the . ?

Full disclosure what i am trying to do:
greate different triggers on a vallue that changes regulary by tiny margins.
say:
2000.20 changes to 2000.18 or 2000.22 no acction but when it changes to 2000.80 or 1999.70 it triggers.
This is for referance I understand there are manyways to do it this is why i am asking for a breakdown instead of just a sollution so i can understand and next time implent it differently or elsewhere

Int will convert it to a whole number. For example int(4.2) will produce 4.

Float will give a number of decimal points. So for example 4.1234|float(2) should produce 4.12.

The float is wrong, see below for the right answer for HA.

1 Like

Nope. The number in the brackets is not a rounding factor. It is the default value that will be substituted if the string can not be converted to a number. e.g.

"1.23456"|float(2)1.23456

"foobar"|float(2)2

2 Likes

My bad, was a quick reply and I was clearly thinking python style not HA!

Thanks my other question remains:

can < = > also be used to say how much increase afther the . ?

ps. is it prefered to ask every question in a new posts ?

I’m not completely sure what you are asking but…

the < = > symbols are comparison operators.

they compare whether the value before is either less than (<), equal to (=) or greater than (>) the value that comes after the operator. they only return values of true or false.

if you want to calculate a deviation away from the test value then you will need to do some math on the right hand side of the operator to accomplish that.

ex

value_1 = 2000.2
value_2 = 2000.8
value_2 > (value_1 + 0.5) it will be true (2000.8 is greater than 2000.7)

value_2 = 2000.7
value_2 > (value_1 + 0.5) it will be false (2000.7 is equal to - but not greater than - 2000.7)

if that doesn’t answer the question then maybe ask the question in a different way to clarify.