At 7pm the memory usage started to grow very quickly and it crashed when it reached 100%; after restarting it, it started growing again
I have a Prism EV charger and 7pm is the time I started charging the vehicle, I have a script that controls the current to limit the maximum power withdrawn from the grid (script in the next post)
I used to do that, but I thought the script was more elegant and efficient
For example with the script I can check every 1s if I have do increase or decrease the current; by using automations I have to setup two separate automations that each check a condition every 1s
You don’t have to “check every 1s” if you trigger on a sensor change.
The automation will be executed each and every time the state of any of your sensors is changed.
Nothing prevents you to put this in a single automation, though. Basically, the “sequence” part can stay the same. Best is to set the mode to “queued”, though, or you might miss events if the automation is already running.
EDIT: Unless you specifically wants it to run every 1sec? Then, use a “Time pattern” trigger.
You’re not doing a “simple” while loop. You’re basically doing an endless loop (until you switch it off).
By essence, HA is asynchronous, and you force it to a synchronous job. Not sure why memory explodes, then, but you can assume it is because memory is allocated at each loop, and you don’t give HA a chance to do garbage collection.
Meh. Triggering on state changes or events would be better than an endless loop or time pattern trigger.
Though I suspect you might fall afoul of the lack of a “button release” event in HA for your intended application. You can vote here for its inclusion here.
So I created a new automation that is triggered by power numeric value change (as often as every 1s)
I created this automation 3 days ago, but I haven’t “used it” (not charged the EV), so it’s triggered, but no action is executed
My HA crashed last night after running smoothly for weeks, so I can only assume it has something to do with this automation (which I have now made asynchronous)
However, memory usage wasn’t ramping up before crashing this time