question

ronski avatar image
ronski asked

Scheduled discharge flow, includes charging time to go as well

Disclaimer: You use this entirely at your own risk, I'm not an expert, and I only started using Node Red and Javascript in March (about 6 weeks ago!). Satisfy yourself that this does what you need, and does it safely, I'm not responsible for any problems however caused, and share this for the community to adapt to their needs.


I required scheduled discharging, which Victron doesn't support, also I couldn't find any available flows, so after some research and a quick bit of learning I've come up with my own.

dashboard-scheduled-discharge.jpg


I've also added a graph, which can be useful for seeing what's going on.

graph.jpg


The aim is to ensure that the battery is discharging the set wattage, so it calculates the grid set point taking into account total PV power, total AC loads and the discharge rate you want, it will then set the grid set point to that value. It calculates this every once every minute, I've built in an adjustable range so you can change the frequency the set point is changed, if the new set point is within + or - the range value of the existing set point it is not changed. This reduces the frequency that the set point changes, I've no idea if changing it too often could cause issues (see this thread), so I've set the timer to run once a minute, and the range value will further reduce the amount of times its changed. There is also a minium SOC of charge setting, once reached just the excess solar will be exported until the timer turns off.

I've been running this for a couple of weeks, making the odd modification, and it seems to be working well.

My grid set point is normally set to 0, so if yours is different you will need to alter the flow so that it sets it back to the value that you use.

There are sliders & reset buttons for the following:

Schedule on off switch.
Maximum grid set point - sets maximum allowed grid export.
Range value - so you can easily alter the range.
Maximum battery discharge to use.
Minimum SOC - stops discharging when reached.

When you first import the flows, you will need to alter the MQTT's flow to suit your equipment, I have two MPPT controllers, and an AC inverter. You will need to change the Victron nodes to suit what you have, and make sure you select the same "Measurement", otherwise it won't work. Another complication you may well have is calculating the total PV, the flow will need altering to add this up correctly depending on what equipment you have. This should all be in the MQTT's flow, there will also likely be stuff in there you don't need, as I also use it in my other flows. You can see which MQTT nodes are used on the Scheduled discharge flow, and remove what you don't need in the MQTT's flow.

Included in the MQTT's flow is a time to go calculator, it will turn Victrons discharge time to go in to days, hours and minutes, and if the battery is charging it will estimate the time to go before the battery is full, it calculates the average over 3 minutes.

The actual timers are built into the flow, but they are easy to edit, alter, and recreate.

There is also a manual control, to use this you need to turn the "Scheduled Discharge" switch off if your are within a timer period, otherwise the grid point will be altered by the scheduled discharge routine. Moving the slider to the positive side will charge the batteries, moving it to the negative side, will discharge the batteries, it literally sets the grid set point, and that's it, reset sets it back to 0.

I've included a screen shot of my pallet, the moment node is not used in these flows.

I've probably missed things, so just ask and I'll try to help, but I can't fix everyone's issues as I am just one person with limited time.

If you notice any problems in my code, then please let me know.

Main MQTT's Flow - there is a lot here not used in the scheduled discharge flow, as I use it elsewhere, so you can delete what's not required.

main-mqtts.jpg

Scheduled Discharge Flow

scheduled-discharge.jpg

Palette

palette.jpg



Edit:22 April 2023. Made some modifications to the scheduled discharge flow, simplified some bits, altered the layout, and changed the timer so it only runs once a minute.

Edit:25 April 2023. Modified the flow so that if there is excess PV when the minimum SOC is reached then the excess will be exported, this stops the battery charging, and full export starting again. Also added a graph with useful information on it.

Edit: 29 April 2023 Fixed a bug which would cause it to start discharging outside of a timer period if you moved the sliders or pressed the buttons. I just deleted the two link nodes for the sliders/reset buttons.

Edit: 29 April 2023. Spotted another minor bug on the chart, the "Grid Set Point" function node at the top for the chart should get its value from msg.payload = flow.get("PresentGridSetPoint");

node-red-scheduled-discharge.zip

ess dischargingscheduled charge
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

1 Answer
markess avatar image
markess answered ·

Wow that's quite a flow... I wrote some Node-Red code to force discharge of ESS system too, keeping battery current reasonably constant, which looks like this. The main advantage over the native ESS behaviour is that if the sun comes out the battery will continue to discharge at a set rate. The grid set-point will not drop below a certain level (from the dashboard), so if the house loads go up the battery works harder (and a stop on SOC % comes from the dashboard)

1681994938391.png

With a dashboard to control it. You can see how the grid set-point tracks the sun going down.


screenshot-20230601-2341502.png


4 comments
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

ronski avatar image ronski commented ·
It did turn into a bit of a behemoth , a lot of it could be done away with if I wanted something more simplified, there is also a lot on the MQTTs flow that isn't relevant to the scheduled discharge flow as its used elsewhere, and I dare say a lot of it can be improved upon - my brother who is a programmer would probably rip it to shreds.


Perhaps you could post your flow, people will then have an option of what to use.


0 Likes 0 ·
graham-willsher avatar image graham-willsher commented ·
Hi @MarkEss,


Thanks execellent.

Do you think that you could post the flow, as I am thinking of moving my current Home Assistant verison of the same to Node Red., and it would save me inventing the wheel again.

Thanks,

Graham.

0 Likes 0 ·
markess avatar image markess graham-willsher commented ·
Hi Graham, sure. If you email mark_nodered@fastmail.co.uk I can send it to you.
1 Like 1 ·
Show more comments

Related Resources

Additional resources still need to be added for this topic