Value Decision per month based on battery SOC

Hello and thanks for the wonderful program.
I´m good at SPS programming and very new in Nodered, so I need little help for my ToDo.

My plan is: My photovoltaik system have a battery and the MQTT values comes and goes to the inverter and from the battery shunt.
Per month are different sun hours that means the battery is in summer month nearly daily full, in winter month nearly daily empty.

The battery SOC is from 100 to 0 % and this value is a String 0-100. Over the MQTT I receive every second the actual value.

I have to set 2 states. One state is Change to Grid, other one is change to Solar.

Example: In March: If it is March then the Nodered have 2 values. Change to Grid at 78%, change to Solar at 80%. This two values are setpoints and specified from me in Nodered.
If the Photovoltaik system charge the battery, this MQTT value increase over 80%, then the decision comes from Nodered: Signal 1: true send to Inverter over MQTT.

If the battery SOC decrease and goes down below 78%, the Nodered send a Signal 2: true send to Inverter over MQTT then the inverter change to Grid mode.

I tried this, but I have some overwhelming and not the correct node found.

Can somebody help me?

Here the Export from that what I tried, but no idea, how I can go forward:

[{"id":"cfc08803.dc72a8","type":"cron","z":"2d5aec04.6c3974","name":"","cronExpression":"0 0 1 * MAR *\t","fireAtStartup":false,"x":210,"y":4560,"wires":[["e163dae2.ce4048","a9fc3605.3c8b08"]]},{"id":"dad8ba43.740b48","type":"cron","z":"2d5aec04.6c3974","name":"","cronExpression":"0 0 1 * FEB *\t","fireAtStartup":false,"x":210,"y":4460,"wires":[["da6b9cde.7ce78","bff97ed.c46d58"]]},{"id":"4aecfac0.9e9784","type":"cron","z":"2d5aec04.6c3974","name":"","cronExpression":"0 0 1 * JAN *\t","fireAtStartup":false,"x":210,"y":4340,"wires":[["babd62fb.04c53","2490ee80.e29d92"]]},{"id":"e163dae2.ce4048","type":"trigger","z":"2d5aec04.6c3974","name":"To Grid 78%","op1":"78","op2":"false","op1type":"str","op2type":"bool","duration":"1438","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":650,"y":4560,"wires":[["8f2bb3f9.befd9"]]},{"id":"a9fc3605.3c8b08","type":"trigger","z":"2d5aec04.6c3974","name":"To Solar 80%","op1":"80","op2":"false","op1type":"str","op2type":"bool","duration":"1438","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":640,"y":4620,"wires":[["3a6bdc1c.4bbf64"]]},{"id":"cb0fff07.555f","type":"mqtt in","z":"2d5aec04.6c3974","name":"","topic":"soc","qos":"0","datatype":"utf8","broker":"d891a2dc.5ed99","x":90,"y":4160,"wires":[["b88361b5.28b09"]]},{"id":"b88361b5.28b09","type":"debug","z":"2d5aec04.6c3974","name":"Batterie SOC %","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":140,"y":4220,"wires":[]},{"id":"8f2bb3f9.befd9","type":"debug","z":"2d5aec04.6c3974","name":"Batterie SOC %","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":840,"y":4560,"wires":[]},{"id":"3a6bdc1c.4bbf64","type":"debug","z":"2d5aec04.6c3974","name":"Batterie SOC %","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":840,"y":4620,"wires":[]},{"id":"da6b9cde.7ce78","type":"trigger","z":"2d5aec04.6c3974","name":"To Grid 83%","op1":"83","op2":"false","op1type":"str","op2type":"bool","duration":"1438","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":650,"y":4400,"wires":[["27fc4390.d0eaac"]]},{"id":"27fc4390.d0eaac","type":"debug","z":"2d5aec04.6c3974","name":"Batterie SOC %","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":840,"y":4400,"wires":[]},{"id":"bff97ed.c46d58","type":"trigger","z":"2d5aec04.6c3974","name":"To Solar 85%","op1":"85","op2":"false","op1type":"str","op2type":"bool","duration":"1438","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":640,"y":4460,"wires":[["e5e3ad93.dafc3"]]},{"id":"e5e3ad93.dafc3","type":"debug","z":"2d5aec04.6c3974","name":"Batterie SOC %","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":840,"y":4460,"wires":[]},{"id":"babd62fb.04c53","type":"trigger","z":"2d5aec04.6c3974","name":"To Grid 88%","op1":"88","op2":"false","op1type":"str","op2type":"bool","duration":"1438","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":650,"y":4260,"wires":[["de2e2946.f69938"]]},{"id":"de2e2946.f69938","type":"debug","z":"2d5aec04.6c3974","name":"Batterie SOC %","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":840,"y":4260,"wires":[]},{"id":"2490ee80.e29d92","type":"trigger","z":"2d5aec04.6c3974","name":"To Solar 90%","op1":"90","op2":"false","op1type":"str","op2type":"bool","duration":"1438","extend":false,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":640,"y":4320,"wires":[["34ffb79d.4d1a58"]]},{"id":"34ffb79d.4d1a58","type":"debug","z":"2d5aec04.6c3974","name":"Batterie SOC %","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":840,"y":4320,"wires":[]},{"id":"d891a2dc.5ed99","type":"mqtt-broker","name":"raspberri","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

Thanks for any idea.
Best regards Herbert

Hi, it is a bit unclear what you want & your flow gives little clues (it really doesnt make much sense).

Here is what I can guess you might want (or at least provide you some clues or a direction)...

Demo flow (note: many assumptions had to be made due to lack of detail)...

[{"id":"b438aaba.fb75a8","type":"change","z":"6fe62fab.dc09d","name":"set payload 2","rules":[{"t":"set","p":"payload","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":200,"wires":[["119399bb.edb976"]]},{"id":"1a10febf.9fcba1","type":"mqtt in","z":"6fe62fab.dc09d","name":"","topic":"soc","qos":"0","datatype":"utf8","broker":"d891a2dc.5ed99","x":190,"y":140,"wires":[["34e1dc5e.7eacc4","5a671927.8de6e8"]]},{"id":"34e1dc5e.7eacc4","type":"debug","z":"6fe62fab.dc09d","name":"Batterie SOC %","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":420,"y":140,"wires":[]},{"id":"eec0411e.f26f2","type":"cronplus","z":"6fe62fab.dc09d","name":"March","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"march","payloadType":"json","payload":"{\"toGrid\":78,\"toSolar\":80}","expressionType":"cron","expression":"0 0 0 1 mar * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":190,"y":360,"wires":[["8fdf3645.a7cc48"]]},{"id":"8fdf3645.a7cc48","type":"change","z":"6fe62fab.dc09d","name":"update flow.limits","rules":[{"t":"set","p":"limits","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":370,"y":380,"wires":[[]]},{"id":"a7caccad.df605","type":"cronplus","z":"6fe62fab.dc09d","name":"Aug","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"august","payloadType":"json","payload":"{\"toGrid\":78,\"toSolar\":80}","expressionType":"cron","expression":"0 0 0 1 aug * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":190,"y":400,"wires":[["8fdf3645.a7cc48"]]},{"id":"8d1a3dc6.73a28","type":"switch","z":"6fe62fab.dc09d","name":"is SOC < flow.limits.toGrid?","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"limits.toGrid","vt":"flow"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":460,"y":200,"wires":[["b438aaba.fb75a8"],["ebd2f8e2.418da8"]]},{"id":"7033f5f0.39658c","type":"debug","z":"6fe62fab.dc09d","name":"state","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":1030,"y":220,"wires":[]},{"id":"119399bb.edb976","type":"change","z":"6fe62fab.dc09d","name":"store flow.state","rules":[{"t":"set","p":"state","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":220,"wires":[["7033f5f0.39658c"]]},{"id":"ebd2f8e2.418da8","type":"switch","z":"6fe62fab.dc09d","name":"is SOC > flow.limits.toSolar?","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"limits.toSolar","vt":"flow"}],"checkall":"true","repair":false,"outputs":1,"x":460,"y":240,"wires":[["7c81f93e.3e4ff8"]]},{"id":"7c81f93e.3e4ff8","type":"change","z":"6fe62fab.dc09d","name":"set payload 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":240,"wires":[["119399bb.edb976"]]},{"id":"5a671927.8de6e8","type":"function","z":"6fe62fab.dc09d","name":"string to number","func":"msg.payload = Number(msg.payload)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":220,"y":200,"wires":[["8d1a3dc6.73a28"]]},{"id":"26f1965f.f1f40a","type":"comment","z":"6fe62fab.dc09d","name":"update limits based on time or year","info":"","x":280,"y":320,"wires":[]},{"id":"fcfd99df.8ea268","type":"comment","z":"6fe62fab.dc09d","name":"monitor SOC and set state accordingly","info":"","x":290,"y":100,"wires":[]},{"id":"d891a2dc.5ed99","type":"mqtt-broker","name":"raspberri","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

↑ requires cron-plus node (but you can change if you wish)

1 Like

Hey thank you very very much for your flow. With so less information so a good flow. unbelievable. Yesterday I try it out. Currently it works. So great!
Also very good to integrate the set values in the month. I can only say WOW. But I changed the cron job to these:* * * * MAR * -- every second in March. So if the Raspberry have a reboot, after 1 second the values are already available and not only first of March.

But one more question I have.

The text with values I will display at the dashboard. Which values are currently to grid and to solar. In each month these values should changed by itself. :wink:
How can I disassemble this text:
{ toGrid: 78, toSolar: 80 }
in 2 separate messages:

Dashboard Text 1: Change to Grid: 78 %
Dashboard Text 2: Change to Solar: 80 %

image

Thanks and best regards from Germany Herbert

You dont really need to. You can access sub properties of a payload for display in a dashboard element. e.g..
change node (set : msg.payload, to : flow.limits) --> UI text - {{msg.payload.toGrid}}
image

But if you must separate them out, then use a change node. e.g...
image

1 Like

Again. THANKS! So quick respons with perfect answer. Thanks. Now I have a perfect solution! Have a N.I.C.E. Day! :ok_hand:
BR Herbert

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.