Hi, All.
Please help me with automation. All I want to do is to switch on the plug when a specific value (avarege price which I calculated somewhere else) drops below 1. Here’s the code which doesn’t work:
`id: ‘…’
alias: PlugON
description: Switches on the plug when the average price is below 1
Thank you!
Could you also explain the basic principle of triger which I still do not understand - does the trigger listens to the value constantly or the trigger triggers on change of the value? Sorry for this unclear question but I home you understand. I want to understand when HA checks if states(’‘sensor.nordpool_percent_to_average’’) < 1 and fires the action
If you have a template in a trigger, HA will evaluate that template whenever any of the entities in the template changes; and the trigger will fire if the template output changes from false to true.
In this case, HA will evaluate your template whenever sensor.nordpool_percent_to_average changes; but because the sensor state is a string, not a number, it will never evaluate to less than the number 1. You need to change it to a number with states("sensor.nordpool_percent_to_average")|float(0) as described.
Much more information in the docs:
Please learn how to format code. For blocks of code, surround it with three backticks:
``` block of code
```
and for inline code, surround with a single backtick `inline code`.
If you don’t do that, the forum software hides your indentation and messes up the quotes with “smart quotes” — see what it’s done to your previous posts.