Template to return true or false for when entity geater than 1

Hi,
I am trying to create a template to return true when value of the entity mentioned below is greater than 1 … is the syntax correct because when trying this in Developer Tools > Template I am getting “Result type: string”

if states('sensor.energy_meter_mains_power') | float > 1

Example for use in a Template Binary Sensor:

{{ states('sensor.energy_meter_mains_power') | float(0) > 1 }}
1 Like

That is not required or valid.

What happens if the test is not true?

You have no else case. This will produce errors.

Also what is this supposed to be?

{ ‘test’ }

As written it is invalid. Posting incomplete examples is a sure fire way to confuse people asking for help.

And, it is still not required. Taras’ solution is the way.

Also your example does not return true / false. Which was the original request. Yours returns ‘{test}’ or an error.

Pointing out that your example is not the solution is very much on topic.

this worked perfectly … thanks!

1 Like