Shelly RGB bulb as the battery SoC indicator!

I have built numerous residential systems, in a zero-feed grid-connected configuration. While interacting with the residents, I am finding it particularly difficult in talking them into using the VRM or the app on their phones in order to optimise their energy usage. That would boost self-sufficiency greatly.

I thought I would help them by setting up a Victron - Shelly integration through Node-RED, by adjusting the colour of a Shelly RGBW LED bulb that would be placed in the living room or the home office: For example, RED would be SoC<20%, warmWHITE would be between 20% and 70%, GREEN would be between 71% and 95%, and when fully charged (above 95%) I would set the bulb to some vivid BLUE or pulsing mode. That way, when the residents would see the bulb turn GREEN or BLUE, they would fire up numerous power-hungry devices.

All systems are connected to the Victron ecosystem and I have also installed the node RED additions for Victron as well as Shelly through the Venus OS large firmware on the Cerbos.

Here’s my flow so far:

The functions contain direct commands to the RGBW bulb, this example is per the 3rd CASE above:

msg.payload =
{
    red : 0,
    green : 255,
    blue : 0,
    white : 0,
    temp : 3500,
    gain : 100,
    effect : 0,
    transition : 0,
    on : true
}
return msg;

However, I find it difficult to better adjust the behaviour when on CASE #2. While on that state, I would like to additionally adjust the colour of the bulb, according to wether the battery is CHARGING or DISCHARGING. Which is the proper way to add the extra node “inside” the flow? One way this could be done (I think) is by adding a second switch after the main one, that would read the charge current of the battery, however, I don’t know how to pick the correct “msg.payload” for the task. Which is the way to select a specific “msg.payload”, when there are more than one funnelling into a node?

Alternatively, I could structure all these extra cases inside the switch node, but I don’t see a way to include an “AND” logic in there…

1 Like

I have the same bulbs and thought about the same thing, though mine was to flash the bulbs when grid was lost.
The hardest part was the pulsing of the light.

Did you manage to get anywhere with this? Could you possibly share your node-red flow, so I can get some ideas on where to start? I usually can get things done, when working by example.

Let me go dig around in my flows. It was one of those projects I started and didn’t quite finish once I manually made the bulbs work with inject nodes.

@thanar went back to check, then I remembered I recently replaced my Shelly’s with Sonoff, they are more of a pain. I may need to reflash them, but have loaded the local lan nodes and will test.
IIRC the shelly node let you control them locally, and wasn’t too difficult to configure.

I am actually getting somewhere with this, my main issue right now is how to include an “AND” logic gate on my flow, please see OP. Thanx for taking a look.

Ok. Before taking a crack at it myself, how I would attempt the logic is along these lines.
Use a single function.
Take a feed from the BMS like battery current, if > 0 then charging, if < 0 discharging.
You can then have a list of if statements with && operators so if (soc >= 20 && soc <40 && current > 0) then colour =blue.
You’d have 8 statements for control, 4 for charging and 4 for discharging.

When I want to use multiple inputs in a function I tend to use flow variables, victron nodes do this by default now (they use global iirc) which means you can call a node once and reference it anywhere.

If I understand you correctly, you would code it on javascript code, right?

Correct. You are using a switch and then have 4 independent functions. Drop the switch and combine the 4 into 1 js function using logical operators which AND the various variables to configure the colour you want.

This is indeed the proper way to do it programmatically. However, I am at under 10% knowledge on js, I would be grateful if you could provide a couple of relative examples.

Attach your json export here as a .zip will have a look and see if I can give you something more concrete to help.

Nick’s suggestion is a much more efficient way to do this, but if you want to avoid too much js the below method should work.

image

Feed the two Victron nodes into a Join node and have it create a key/value object as below. I recommend setting the Victron nodes to only update on change, hence ticking the “and every subsequent message” option.

Then tell the switches to look at the appropriate property, the first one will be msg.payload[“Battery SoC (%)”] and the second will be whatever battery state node you are using.

image

You can find the path for a specific property using the debug console as below.

image