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

[Q] Does the "best-save" node take into account the existing schedule when prices are updated? #28

Closed AlecTBM closed 2 years ago

AlecTBM commented 2 years ago

Thank you for the project What I mean is when I am feeding it the prices for the next day at the evening (around 16-17), do the node take into account what the schedule have been until that point? Example, if the rule "Max per sequence" is 12 hours, and when the time is 16:00, it have been off for 10 hours, new prices for "tomorrow" is loaded, do it take it into account that the output have been of for 10 hours, and need to be turned on again in two hours? And does it differ if you choose "Whole data set" or "From current hour"?

ottopaulsen commented 2 years ago

It is supposed to take into account the schedule that has passed. However, I am not sure this is working properly if you have selected to plan from current hour. I will have to check that up. If you have any information that can help me, please put it in here. What I need is the prices that are sent as input to the node, as well as the complete payload on output 3, and an explanation of what is happening.

AlecTBM commented 2 years ago

For a test I have actually saved all the outputs from the output3 in a file for some days now (forgot to stop it). I can clean it up a bit and share it later 😊

AlecTBM commented 2 years ago

I have found some bugs in my handling of the prices before sending them to the best saver node, so I don't think the data I have are of any value for you. I will see if I found any problems after the fix and upload if I find something

ottopaulsen commented 2 years ago

In version 3.3.0, the schedule is always calculated using all data received. The schedule from current hour was removed as it was not working.

Can we close this issue?

AlecTBM commented 2 years ago

Yes it can be closed 😊 thank you

AlecTBM commented 2 years ago

I had a look now, and it seems that it do not keep the past schedule in mind. image This graph is the schedule in cyan (last value, old values are overwritten), and the actual state of the relay on purple.

I have all the inputs and output3 saved as json for some weeks, so I have uploaded it for february (actually the beginning of february looks quite good): bestsave.txt

ottopaulsen commented 2 years ago

First please verify that Node-RED actually saves data between reboots:

  1. Restart Node-RED
  2. Click on the node.
  3. Select Context Data in the menu to the right.
  4. Click the refresh-button in the node-section.
  5. Now you should see config, lastPlan, lastPriceData as well as data for multiple dates.

Do you see those saved data? If not, open /config/node-red/settings.js. It shall contain something like this:

  contextStorage: {
    file: { module: "localfilesystem"},
    default: { module: "memory" }
  },

Please let me know what you find out.

AlecTBM commented 2 years ago

I followed your instructions (after updating to 3.4.1 btw), and after a restart of node-red there is only the config in the context of the node. I have two context stores, and the default is memory. However, I am not restarting Node-RED every day (you can see where I have manually injected the prices again, this is because of a node-red restart), so the issue that I see is that it is calculating a new schedule for the past hours that don't match up with what actually happened.

ottopaulsen commented 2 years ago

Well, the context is clearly not saved, so that may be the problem here. What does your contextStorage setting look like exactly?

AlecTBM commented 2 years ago

This is my settings: contextStorage: { default: "memoryOnly", memoryOnly: { module: 'memory' }, file: { module: 'localfilesystem' } },

However, this issue is not related to any restart of node red, so the saved context in memory should not been lost when the new prices are received.

ottopaulsen commented 2 years ago

I suggest you try the contextStorage settings I posted above, or try to figure out why context is not saved.

AlecTBM commented 2 years ago

The schedule get saved to context, but to the default context store which is memory (same as yours settings): image

The settings you posted should practically be the same as mine, the only difference is that I have named the default as "memoryOnly" (copy paste from the NR docs). Just to be sure I will change my settings to match yours. What are the expected result after changing the settings?

For completeness sake, here are the graph and data since the 17.2 (purple is actual state, blue is schedule): image bestsave.txt

EDIT: last time I restarted node-red before making this comment was the 17.2.

ottopaulsen commented 2 years ago

I just realised that all this context is only stored in memory, so you're right. Nothing has been stored over restart. I will make a fix for this. Thanks for not giving up :-)

AlecTBM commented 2 years ago

No problem, and to my suprise changing the context store settings actually show a change in the graph after I did the change: image Purple is schedule and cyan is actual.

This result is surprising for me, but there might be a bit too early to conclude. However, if this is correct, I don't think demanding a certain context store settings is the way to go 😊 ours was for all purposes identical, just that you did not name your default store, but I did.

AlecTBM commented 2 years ago

Apparently it was a bit too early to conclude as it again have started to not consider the past schedule. image Cyan is actual, purple is schedule. Past 7 days. Actual input and output of the node for these days. bestsave.txt

Note that I have not restarted or redeployed node-red in this timeframe. And my node context looks like this at the moment: image

Just a thought from me, I am always sending both todays and tomorrows prices. Is this correct of me? or should I only send for tomorrow since the node already know todays?

AlecTBM commented 2 years ago

Any ideas @ottopaulsen ?

ottopaulsen commented 2 years ago

Sorry, I have very little time for this at the moment. About input prices, I always send all prices I get, that is today and tomorrow. That should not be a problem. Are you sure you are running the latest version? I thought I had fixed so those passed days before yesterday are deleted.

AlecTBM commented 2 years ago

No problem, this is not a big issue 😊 I have not updated for a while to not disturb the logging and since I did not see anything in the changelog that impacted this. However, I am updating now.

Edit: Did miss that node-red 2.2 is required, so had to roll back to version 3.4.1. I will update everything soon, just not tonight 😊

ottopaulsen commented 2 years ago

As mentioned in another issue, changes have been made to how context storage is used. Install version 3.5 to try this.

I am not sure how this relates to this issue, so please give me feedback.

Read about the changes to how context storage is used in the documentation for the Best Save and Lowest Price nodes. Just search for context.

AlecTBM commented 2 years ago

I have updated and will report back. Thanks

AlecTBM commented 2 years ago

Hello. The context store seem to work. But it still seems like it still dont take into account the existing schedule, or if it does, it is not 100% strict.

ottopaulsen commented 2 years ago

Guess I need to know what data you are using, what result you get and what you expect.

ottopaulsen commented 2 years ago

Closing due to no response