I try to turn off the plug, when i’m not home ( smartphone not at home ).
But it’s a plug for printer3D.
Conditions:
if power < 0.50A
and smartphone not home ( i’m out )
for xxx second. Plug turn off.
For trying,
i have deleted the smartphone condition. and modificated the 0.50 and 600 deleted the ‘’ . Then i have deleted 600 and write 10 ( second ).
then i have restart Hass, and shutdown worked.
Now, i have put the plug on for a second test, without any change. But the automation do not shutdown it again why ?
That’s actually not true. It will work as is with the quotes. The trigger code will convert the below value to a float and the for value to an int.
Of course the quotes are not required here and it makes more sense to enter the values as numbers instead of strings, so I would agree the quotes should be removed, but not because they have to be.
The problem may be that the sensor is not changing. It has to change to a value that is below 0.5, and then stay below 0.5 for 600 seconds (i.e., 10 minutes.) Once it does that the condition will be checked.
So, if it goes below 0.5, and stays below 0.5 for 10 minutes, but you’re still home, then it won’t trigger again just because you leave home.
A trigger watches for some event to occur. In this case it was watching for the sensor to change to a value below 0.5 and then stay below 0.5 (i.e., either not change again at all, or if it did change, change to a value that is still below 0.5) for 10 minutes. Once it did that the trigger would “fire.” It will not fire again until the value changes to 0.5 or above and then back to below 0.5 for 10 minutes.
So, as I explained, if that happened when you were home, the automation would not run. So what I suggested was to add another trigger that watches for you to leave home. Then I added another condition that checks if the sensor value has been below 0.5 for at least 10 minutes.
The idea is, the automation watches for both events, and then whenever either occurs (sensor below 0.5 for 10 minutes, or you leave home), it checks to make sure that both conditions are true (sensor below 0.5 for at least 10 minutes and you’re not home), and if so, the automation runs.
What is “better” is completely dependent on your own particular situation. There are many, many ways to do that. There are hundreds, if not thousands, of topics on this forum regarding that one question.
@pnbruckner
Hey there,
i haven’t restart yesterday my Hass. But it’s looks like there is a problem with the code.
I can’t restart Hass.
Invalid config for [automation]: [for] is an invalid option for [automation]. Check: automation->condition->1->for. (See /config/configuration.yaml, line 21).
Ah, ok, now I see. I’ve got too many conversations going on at the same time!
I forgot the numeric_statecondition does not accept for.
Without going back and re-reading everything, I can say a common way to deal with this is to create a template binary sensor that is on when that entity’s numeric state is below 0.5, then use the binary sensor in the trigger and condition instead.