State of a sensor derived from two entity with float

how do i write this with a float insread of the precise number of watt

{{ is_state('switch.monitor_2_power', 'on') and is_state('sensor.monitor_2_power_potenza','12.7') }}

You convert the state string to a float by using the states() function then the float filter. You can then use whatever comparison operator is appropriate for your needs.

{{ is_state('switch.monitor_2_power', 'on') and 
states('sensor.monitor_2_power_potenza')|float(0) == 12.7 }}

if i want it to be more or less than 12 i only have to change == with > or < right?

Yes

1 Like