Solar Hot water switching

Hi, this is my first Node Red attempt, so go easy :wink:
Its working as required, so Im just after advice on how to do it better / more efficiently and to learn a bit more.

This is a flow to divert solar power into the hot water heater element when certain conditions are met.
The solar system also has battery

Im checking time per minute (probably inefficient ) but due to frequently changing solar values want to keep it fairly regular. 1 minute is for testing, I can happily expand it to 5/10 mins etc

There are 2 time range nodes as one operates during solar hours, the other during cheap / free power

Im checking:

  • Water temp (keep over 60)
  • Electrical load (keep under 4500)
  • Solar KW (Send direct to HW if over 3kw, through battery check if 1.5-3kw - battery > 60%, or 0-1.5 if battery over 90%)
  • Battery state of charge (Over 60% > send to HW, Under 60% send to battery unless high solar kw)

If it passes tests, element is turned on for 15 minutes. 1m loop, checks values and lets 15 min delay run if values remain sufficient else turn off element . If the water is over 60 and element on, I add a 10 minute delay to boost the water to max (about 65) so that its not bobbing up and down at the 60 degree check

During the course of the day, this provides a balanced heating of water whilst keeping house loads under battery max kw (5)
This way no power is drawn from the grid.

I guess theres many ways to do this - what stands out as the obvious thing to increase efficiency and readability?
Thanks!

1 Like

That probably works, because it’s so many checks and switches I would do it all in a function node.
The function node would do all the checks and have 6 outputs (if I count your branches correctly).

It requires real coding but gives a more compact sequence.

But your flow seems to be as optimized as it can be with standard nodes.

1 Like

Ive dropped out a couple of checks and switches replacing them with a couple of functions (this is one of them)
Cheers for the ideas!

const ha = global.get('homeassistant').homeAssistant.states;

var x = msg.payload
var bat_soc = parseInt(ha["sensor.solar_battery_soc"].state);
var hwc_power = ha["switch.shelly1pm_e89f6d863b51"].state;

var msg1 = {payload: bat_soc, topic: "bat LOW - OFF"};
var msg2 = {payload: bat_soc, topic: "bat OK - ON"};
var msg3 = {payload: bat_soc, topic: "BYPASS - ON"};

if (x > 0 && x < 1500) {
    if (bat_soc < 90) {
       return [msg1, null, null];  
    }
    if (bat_soc >= 90) {
       return [null, msg2, null]; 
    }
}
if (x >= 1500 && x <= 3000) {
    if (hwc_power) {
        return [null, null, msg3];
    }
    else {
        if (bat_soc >= 60) {
           return [null, msg2, null];  
        }
        if (bat_soc < 60) {
           return [msg1, null, null];  
        }  
    } 
}
if (x > 3000) {
      return [null, null , msg3];
} 

1 Like

Old post, i know, but would you mind sharing the node flow as a starting point for my own setup?

Many thanks!