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

[Lowest Price Node] No price data when using dynamic configuration #59

Closed gulli1986 closed 2 years ago

gulli1986 commented 2 years ago

Hello,

I am currently using a dynamic configuration on the lowest price node to adjust the amount of hours ("hours on") based on the state of charge of my car. It has been working fine so long however I discovered today that I sometimes get an error message after inputing the dynamic configuration to the node;

nodered

It seems like the lowest price node "forgets" the saved prices once the dynamic configuration is sent to the node. I just updated to Power Saver [v3.5.5], can this be related?

It looks like the error is showing after some time, sometimes it works, sometimes it doesn't.

ottopaulsen commented 2 years ago

So when you send one config change, you get first Using saved prices and then No price data, is that correct?

If you upgraded recently, please try to delete the node and create it again, just to make sure there is nothing wrong in the nodes context. Alternatively delete all the context data and keep the node. You find the context data by selecting the node, then select Context Data where you see the debug window, then click the refresh button for Node. You should see data for context, lastPlan, lastPriceData, lastSource and a coupe of dates. It is safe to delete everything.

See if this helps first. If not, copy config and paste it here. Also paste the message you use to change config.

gulli1986 commented 2 years ago

Hello Otto @ottopaulsen. Thanks for the help. I tried both removing the node and deleting context data without any help. That is correct as you mention, I first get Using saved prices then immediately No price data.

This is the message I use to change the config:

{"payload":{"config":{"fromTime":"06:00:00","toTime":"18:00:00","hoursOn":1,"doNotSplit":false,"sendCurrentValueWhenRescheduling":true,"outputIfNoSchedule":false,"outputOutsidePeriod":false}},"data":{"entity_id":"input_button.update_smart_charging","old_state":{"entity_id":"input_button.update_smart_charging","state":"2022-06-13T06:51:56.288304+00:00","attributes":{"editable":true,"icon":"mdi:ev-station","friendly_name":"Update smart charging"},"last_changed":"2022-06-13T06:51:56.288688+00:00","last_updated":"2022-06-13T06:51:56.288688+00:00","context":{"id":"01G5DXAMZVFJMDYB6S4WSQ8DP0","parent_id":null,"user_id":"6923aa91f7ec459685e9800a5fb3c489"},"original_state":"2022-06-13T06:51:56.288304+00:00"},"new_state":{"entity_id":"input_button.update_smart_charging","state":"2022-06-13T06:54:39.687020+00:00","attributes":{"editable":true,"icon":"mdi:ev-station","friendly_name":"Update smart charging"},"last_changed":"2022-06-13T06:54:39.687180+00:00","last_updated":"2022-06-13T06:54:39.687180+00:00","context":{"id":"01G5DXFMJ5XK69G6GWZ9NB428R","parent_id":null,"user_id":"6923aa91f7ec459685e9800a5fb3c489"},"original_state":"2022-06-13T06:54:39.687020+00:00","timeSinceChangedMs":10}},"_msgid":"382112dd95b3939d"}

Here it is easier to read:

Node

Basically I have two input datetime (start and end time for charging) and one input number (battery percentage remaining) that I put together in a payload to change the configuration dynamically and adjust the numbers of Hourson

ottopaulsen commented 2 years ago

The config message only needs to hold the information you want to change, so if you only want to set the number of hours, this message should be enough:

{
    "payload": {
        "config": {
            "hoursOn": 1
        }
    }
}

However, I doubt that is the reason.

Can you look what is stored in the context for the node. Here is an example from me:

image

Verify that the lastPriceData is saved in file and that the config is saved in default.

Then send a config message, and check the context again. Does it still contain the same data?

gulli1986 commented 2 years ago

I did some further testing as you mentioned. Sending only the necessary config did not help, however looking at the context data for the node as you proposed I found out it was empty which explains the No price data.

As soon as I update the prices trough the Price Receiver node, the context data fills in accordingly and the error disappears. My plan was to update the prices as soon as my charging cable was connected to the car. However it looks like it sometimes do not register the connection and hence the prices are not updated in the Lowest price node.

As a workaround I now update the prices / schedule as soon as a new dynamic configuration is pushed to the node. It looks like it is working well.

Thanks for you time and the work you do Otto, much appreciated!