ottopaulsen / node-red-contrib-power-saver

A Node-RED node to saver money by turning off when the power is most expensive
Other
71 stars 17 forks source link

Persistent schedule #25

Closed AlecTBM closed 2 years ago

AlecTBM commented 2 years ago

Hello

I was wondering if is it possible to make the schedule persistent so if node-red is restarted the schedule is kept. Another option is to make it possible to inject a schedule to the best-saver node at start up.

ottopaulsen commented 2 years ago

Good idea to load a saved schedule on startup. What would be the use case for injecting a schedule?

AlecTBM commented 2 years ago

Thank you @ottopaulsen The use case for injecting a schedule was just as an alternative to making the schedule persistant. Then I could re inject the schedule at startup. If the node handles persistant by it self, then i don't see a need for injecting a schedule 😃

ottopaulsen commented 2 years ago

In version 3.2.0, the last previously received prices are used to create a schedule on startup. This should give the same result. I haven't tried this so much, so please give it a try and provide feedback.

AlecTBM commented 2 years ago

Just updated and got an warning during start-up and a warning in the palette manager. image image

At first inspection it seem to work however 😊 restarted the flows and it seem to hold its state

ottopaulsen commented 2 years ago

Thank you for notifying, @AlecTBM. This should be fixed in version 3.2.3. Please try and give feedback.

AlecTBM commented 2 years ago

Thank you for notifying, @AlecTBM. This should be fixed in version 3.2.3. Please try and give feedback.

The warnings are gone after the update to 3.2.3 😊 Regarding the persistent of the schedule I will need some more time to be sure. However, I can say that if I restart node-red, it looses the schedule, but if I restart all the flows or does any redeployment, it seems to be kept. Well done 😊

AlecTBM commented 2 years ago

I found out today that my test yesterday actully gave the wrong result since I only looked on the node status text. So the schedule was lost either when I restarted the flows, and/or redeployed. But the status text remained showing the next action. I will check some more later, but is there another way to see if it have a shedule or not?

ottopaulsen commented 2 years ago

The status text should be fixed in version 3.3.0. Please verify and report back.

otsafe commented 2 years ago

I just upgraded to 3.3.0, and can confirm that shedule is lost on deploy. Text is kept, but the node doesn't send anything on the outputs when the time is ready. Else thanks for this great plugin.

ottopaulsen commented 2 years ago

I have done some work on this now, and it would be nice if you could try it out and see if the functionality is useful, and if it works as expected.

On the Best Save and Lowest Price nodes, you can now select what config storage to use. If you have set up a file based context storage, and use this, the price data is saved over restarts. In order to re-schedule after a restart, there is a new dynamic command replan that can be used. It can easily be sent using an inject node, as described here.

Please try and give feedback.

AlecTBM commented 2 years ago

Nice Otto 😊 I have updated now and will report back

ottopaulsen commented 2 years ago

Assuming this is ok