Using excess power for hot water using Node Red

Hello,

I´m was using the folowing Blockly script with great success for the last year in iobroker.
Then I switch to Home Assistant and unfortunately Blockly is not avfailable there.

The whole idea can be found here : https://forum.iobroker.net/topic/65245/warmwasser-und-photovoltaik-mit-blockly/16?_=1713172125491

I started using Node Red but found a lot of “proper” nodes missing :frowning_face:

I do believe the whole structure must be changed…

Any ideas how to approch this task?

Regards Dom

Could you switch the blocky script to English?

Hi Mike,

unfortunately not because the system is not running anymore :frowning:

The logic is very simple though:

While loop:
Set variable “heater” to value of variable “switch”
When there is enough power (>2000) and the batterycharge is suffitient (>50%) and it´s between (7am-5pm) set variable “heater” to true.
When there is not enough power (<1000) and the batterycharge is suffitient (>50%) and it´s between (7am-5pm) set variable “heater” to false.
When there the batterycharge is not suffitient (<50%) or it´s not between (7am-5pm) set variable “heater” to false.
If variable “heater” is unequal variable “switch” set variable “switch” to value of “heater”.

Here is a very basic node red sceme but it´s not working as intended ;-(
Actually it´s doing nothing, despite the fact it says different?!

But the idea is straight forward.

While PVLeistung (mean PV Power) is hight and Batteriestatus above 50% and while within the time range turn heater on and if not in the time range turn heater of.

The same must be done for PVLeistung <1000 and Batterie <50% to turn everything off.

But it does nothing…

I´m missing the functionallity to put the Batterystatus after the PVLeistung-node and make the decision to turn on or off? Hmm Any ideas?

Device is likely the wrong node to start with. Event state and trigger node are the two primary starts to a flow. Use a trigger node and put the power entity where shown. Set the state to > 2000. Take note of the drop downs set to number

From there a current state can check the battery level > 50 and the node will fire from the top. All nodes that evaluate to true fire from the top.

image

There is also a turn off sequence in the below

[{"id":"b6189fe1e5e7132d","type":"trigger-state","z":"0a325c35fc29f44e","name":"","server":"","version":4,"inputs":0,"outputs":2,"exposeAsEntityConfig":"","entityId":"power","entityIdType":"exact","debugEnabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":">","comparatorValueDatatype":"num","comparatorValue":"2000"}],"customOutputs":[],"outputInitially":false,"stateType":"num","enableInput":false,"x":190,"y":1460,"wires":[["0ed55bdec75e3b4d"],[]]},{"id":"0ed55bdec75e3b4d","type":"api-current-state","z":"0a325c35fc29f44e","name":"","server":"","version":3,"outputs":2,"halt_if":"50","halt_if_type":"num","halt_if_compare":"gt","entity_id":"battery","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":460,"y":1460,"wires":[["2b6b7d318692ddbe"],[]]},{"id":"2b6b7d318692ddbe","type":"time-range-switch","z":"0a325c35fc29f44e","name":"time range","lat":"","lon":"","startTime":"07:28","endTime":"goldenHour","startOffset":0,"endOffset":0,"x":710,"y":1460,"wires":[["26f5588994bb66f4"],[]]},{"id":"26f5588994bb66f4","type":"api-call-service","z":"0a325c35fc29f44e","name":"heater on","server":"","version":5,"debugenabled":false,"domain":"","service":"","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":920,"y":1460,"wires":[[]]},{"id":"a3a908d118138e86","type":"server-state-changed","z":"0a325c35fc29f44e","name":"","server":"","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"Battery","entityIdType":"exact","outputInitially":false,"stateType":"num","ifState":"50","ifStateType":"num","ifStateOperator":"lte","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":180,"y":1520,"wires":[["048c35594de6f669"],[]]},{"id":"e61a8257dbde751e","type":"server-state-changed","z":"0a325c35fc29f44e","name":"","server":"","version":5,"outputs":2,"exposeAsEntityConfig":"","entityId":"power","entityIdType":"exact","outputInitially":false,"stateType":"num","ifState":"2000","ifStateType":"num","ifStateOperator":"lte","outputOnlyOnStateChange":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":180,"y":1580,"wires":[["048c35594de6f669"],[]]},{"id":"048c35594de6f669","type":"api-call-service","z":"0a325c35fc29f44e","name":"heater off","server":"","version":5,"debugenabled":false,"domain":"","service":"","areaId":[],"deviceId":[],"entityId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":460,"y":1540,"wires":[[]]}]

Hi Mike,

thank you very much for your help.

Now it looks like this:

And it is doing something :slight_smile: Now I have to check which enteties are the correct ones :slight_smile: What do you mean by turn off sequence?

Greatings Dom

This time adjustment node (orange) does not work ;-( Any idea why?

Ohh man,

I just found out that fronius cancled a few features like PV Power, now I have to calculate this manually. By multiplying current and voltage. I do have both enteties but there is no multiplying node?

Pretty much every node in node red is capable of multiplication thorough JSONata. For this particular case it would be better to create the sensor in HA. This way it is available for other automations, energy dashboard and it’s history can be logged. We will use a template to accomplish this.

Add to configuration.yaml in your config folder:

template:
  - sensor:
      - name: "Average temperature"
        unit_of_measurement: "W"
        device_class: power
        state_class: measurement
        state: >
          {% set current = states('sensor.current_sensor') | float %}
          {% set volts = states('sensor.voltage_sensor') | float %}

          {{ (current * volts) | round(1, default=0) }}

Did you set the lat and long in the node. The time nodes won’t hold the coordinates, so you’ll need to add it every time you bring a new one out to the work space. or right click and copy a node already deployed then the coor. are copied.

You are my man :slight_smile:
That did the trick!

SO I will test this around midday.

Thanks again.