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
123
(Taras)
May 24, 2022, 2:59pm
2
Example for use in a Template Binary Sensor:
{{ states('sensor.energy_meter_mains_power') | float(0) > 1 }}
2 Likes
tom_l
May 24, 2022, 10:49pm
4
vingerha:
you may want something like this?
That is not required or valid.
tom_l
May 25, 2022, 4:56am
6
What happens if the test is not true?
You have no else
case. This will produce errors.
vingerha:
{% if states('sensor.powerplug_living_couch') | float > 1 %}
{ 'test' }
{% endif %}
Also what is this supposed to be?
{ ‘test’ }
tom_l
May 25, 2022, 7:00am
8
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