question

Richard Thornton avatar image
Richard Thornton asked

Battery charge "auto" mode in node-red

Hi,

Please help Obi-Wan.

I'm a bit of a newbie, programming & logic hurts my head, please be gentle.

I have a large home battery (48v nominal, 19.2kwh capacity) with a dumb BMS (no communication bus but I don't have to worry about safety or slowing the charge rate when it's nearly full, it's LTO and supports up to 400A charge/discharge) and a Victron 1000A SmartShunt feeding it's data into node-red already. The grid AC battery charger/discharger is controlled through node-red also. Basically I just activate charge or discharge (selling my battery power to the grid during a price spike) and tell it the amount of watts and it will continue until I stop it, very manual, it becomes a problem when I'm sleeping.

Can someone please help me with a loop that I can implement that takes a mode (charge/discharge), target SoC (%) and duration (to reach that SoC) and outputs a signal to either charge or discharge and how many watts, max charge rate is 3000w (limited to this because my battery is unsupported), max discharge 5000w?

For example... I envisage enabling charge at 2100, setting it to target 45% SoC by 0600, let's say the current SoC is 50%, so basically do nothing until 45% and then it needs to cover the battery load (~400W overnight). Obviously if SoC is less than target SoC it has to charge at higher than 400W. Daytime is a harder problem as I have solar panels that can charge the battery through a seperate inverter and the appliances on in the house change the load dramatically so the charge rate will be much more fluid.

For "bonus" points it would be fantastic if the flow could incorporate price, for example, say it waited to after around 0100 when its cheapest (I have wholesale power pricing that changes every 5 minutes, node-red also has the power pricing ingested) and pulled in power as long as the cost was under a certain threshold (lets say 22c) for that 5 minutes. I envisage dividing the charge/discharge set duration specified into 5 minute chunks, 12 chunks per hour, for 5m at 3000w you get 250w per chunk, so the loop checks the price for the chunk and decides to charge or not for that chunk, if the price doesn't get low enough perhaps a lower SoC could be maintained, a target SoC "lookup" table based on price, so under 22c it is 45%, 25c is 40% & 30c is 35%...

Let's say the SoC is 45% and the target is 45%

  • 2100 - 0100 too expensive
  • 0100 - 0105 (SoC now 37%, so maintain 400w (2000w over next 5 hours plus add 1600W lost earlier so 3600w) charge 3000w price is 21c (3600w - 250w = 3350w)
  • 0105 - 0110 price 23c no charge
  • 0110 - 0140 charge 3000w price 20c (3350w - 1500w = 1850w)
  • 0140 - 0200 price 24c no charge
  • 0200 - 0235 charge 3000w price is 21c so only 100w remain (1850w - 1750w)

Probably there could be a lookup table that took the duration and divided it into 5m blocks, like 2100 - 0600 is 108 blocks and just select the blocks you need evenly spaced and try the next block if the chosen one is too expensive, say of the 108 blocks you need 20 for 5000w, choose block 1, 6, 11, 16...if block 1 is too expensive try block 2...

As I said the cost consideration adds a lot of complexity and I'm really focused on getting the "easy" part done but I guess it probably makes sense to use the maximum charge rate of 3000w with a known price block, better the devil you know.

Apologies, this post is long.

Thanks!

Richard

SmartShuntNode-RED
2 |3000

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

0 Answers