I am trying to switch on my hot water when teh solar is producing enough and the good lady isn’t cooking. The hot water draws 4kW which I am using as threshold. I have crafted the value_template:
I’ve tested it in Developer Tools - Templates and if works returning “True” and “False” but when I test the same code in the automation it comes up “Condition did not pass”. Is there something I’m missing in the way automatons work?
The automation cut and pasted:
alias: Turn Hot Water On
description: Turn on Hot Water if Solar production is > 4kW
triggers:
- trigger: time_pattern
minutes: /1
conditions:
- condition: state
entity_id: switch.sswitch_0
state:
- "off"
- condition: template
value_template: >-
"{{ ((states('sensor.solar_power') | float(0)) -
(states('sensor.load_power') | float(0)) >
float(2))}}"
actions:
- type: turn_on
device_id: some device
entity_id: some entity
domain: switch
mode: single
It’s a bit hard to read your code when it’s not formatted correctly.
But this part: >- means you should not have quotes around the template.
So remove the " " from the template and try again.
Keep in mind that if your load sensor fails then this will almost always be true.
You should include a condition that load sensor has a proper value.
Don’t know if you saw the edit I did before about adding another condition to make sure load sensor is valid value.
Your template will make it default to 0.0 meaning solar power will most likely be larger and thus switch on the water heater.