Drip Irrigation using NodeRed

Hi There.
Finally it is time to continue with my home assistant tasks. I used to have an automation just within Home Assisstant. I am now trying to the same thing with Node Red. I am trying to learn this extremly powerful language but it is quite a rough start.
This is the working Automation used to have

alias: Tropfbewässerung Automatik
description: ""
trigger:
  - platform: state
    entity_id: input_boolean.tropfbewasserung
    from: "off"
    to: "on"
condition: []
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id:
        - switch.rasensteuerung_rasen_4
        - switch.rasensteuerung_rasen_5
        - switch.rasensteuerung_rasen_6
  - delay:
      hours: 0
      minutes: 30
      seconds: 0
      milliseconds: 0
  - service: switch.turn_off
    target:
      entity_id:
        - switch.rasensteuerung_rasen_4
        - switch.rasensteuerung_rasen_5
        - switch.rasensteuerung_rasen_6
    data: {}
  - service: switch.turn_off
    data: {}
    target:
      entity_id: input_boolean.tropfbewasserung
mode: single

now I am trying to do the same in NodeRed with very little success. This is a screen shot or my NodeRed.


The input boolean is working, it shows active in my Dashboard but the irrigation itself is not starting. I tried it with
call Service switch_turn on but it does not do anything. What am I doing wrong. Do vou guys have any tips to guide me into the right direction.

Thank you

Can you post your Node Red code (in compact form so it’s on one line)., as superficially it looks like it should work.

One problem with your code is that multiple wires coming out of a node ‘duplicates’ the flow. So you have one message that triggers the flow, but this is connected to 3 turn-on service nodes, so now you have 3 messages in play that result in 3 delay node calls, and therefore 12 turn-off service calls. It won’t cause a problem, but the delay should be connected to the output of the trigger, not the outputs of the turn-on calls. Joining 3 outputs to one input does not magically join the messages. To do this you would have to use a join node, which is unnecessary in this case because the delay can start at the same time as the turn-on calls.

Do you mean that? I inserted a delay for each smitch but it does not make a difference

[{"id":"e3db9c9daedf9bd1","type":"api-call-service","z":"c753663a45a2236f","name":"Hochbeet","server":"92183824.74a3e8","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":["b67eb5c4b798ff3c71fa4c4e8dfb9e1c"],"entityId":["switch.rasen_esp8266_tropf_hochbeet_4"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":520,"y":100,"wires":[["11748743f20a41d4"]]},{"id":"9288700f1e594308","type":"api-call-service","z":"c753663a45a2236f","name":"Haus","server":"92183824.74a3e8","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.rasen_esp8266_tropf_haus_3"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":510,"y":200,"wires":[["11748743f20a41d4"]]},{"id":"82a824d3d32997c2","type":"api-call-service","z":"c753663a45a2236f","name":"Terasse","server":"92183824.74a3e8","version":5,"debugenabled":false,"domain":"switch","service":"turn_on","areaId":[],"deviceId":[],"entityId":["switch.rasen_esp8266_tropf_terrasse_2"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":520,"y":160,"wires":[["11748743f20a41d4"]]},{"id":"11748743f20a41d4","type":"delay","z":"c753663a45a2236f","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":750,"y":140,"wires":[["f4c074c69a108eaf","3f4120f883bbad83","ee9b48a4771033a5","ec0170732f253208"]]},{"id":"f4c074c69a108eaf","type":"api-call-service","z":"c753663a45a2236f","name":"Hochbeet","server":"92183824.74a3e8","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.rasen_esp8266_tropf_hochbeet_4"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":940,"y":80,"wires":[[]]},{"id":"3f4120f883bbad83","type":"api-call-service","z":"c753663a45a2236f","name":"Terasse","server":"92183824.74a3e8","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.rasen_esp8266_tropf_terrasse_2"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":940,"y":140,"wires":[[]]},{"id":"ee9b48a4771033a5","type":"api-call-service","z":"c753663a45a2236f","name":"Haus","server":"92183824.74a3e8","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["switch.rasen_esp8266_tropf_haus_3"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":930,"y":200,"wires":[[]]},{"id":"ec0170732f253208","type":"api-call-service","z":"c753663a45a2236f","name":"Tropfautomatik","server":"92183824.74a3e8","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["input_boolean.tropfbewasserung"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":960,"y":260,"wires":[[]]},{"id":"7a1e30717dacf86f","type":"server-state-changed","z":"c753663a45a2236f","name":"Tropfautomatik","server":"92183824.74a3e8","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.tropfbewasserung","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"On","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":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":80,"y":140,"wires":[["31a131fe2153952f","7d93c576684cc313","2f9a77c2346b91fd"],[]]},{"id":"31a131fe2153952f","type":"delay","z":"c753663a45a2236f","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":300,"y":220,"wires":[["e3db9c9daedf9bd1","9288700f1e594308"]]},{"id":"2f9a77c2346b91fd","type":"delay","z":"c753663a45a2236f","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":300,"y":160,"wires":[["82a824d3d32997c2"]]},{"id":"7d93c576684cc313","type":"delay","z":"c753663a45a2236f","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":300,"y":100,"wires":[["e3db9c9daedf9bd1"]]},{"id":"92183824.74a3e8","type":"server","name":"Home Assistant","addon":true}]

To me that looks awful to read :slight_smile:
I shall give it a closer look this evening. But thanks so far

One thing you need to understand with NodeRed is that you can make several output connections from a node, but this will make each output run its on flow.
This means that if you put several input flows to a node, then the standard way is to treat each flow separately.
The exception is a few nodes, like a the merge node that collects the flows into one output flow based on some rules or a delay node which might only send the last flow on when the delay times out.

1 Like

I sort of made it work. I simply used the group to turn it on and off. But it also works with a seperate Node for each event (did not know that before).

[{"id":"ec0170732f253208","type":"api-call-service","z":"c753663a45a2236f","name":"Tropfautomatik","server":"92183824.74a3e8","version":5,"debugenabled":false,"domain":"switch","service":"turn_off","areaId":[],"deviceId":[],"entityId":["group.tropfbewasserung_all"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":720,"y":220,"wires":[[]]},{"id":"92183824.74a3e8","type":"server","name":"Home Assistant","addon":true}]

Only problem now is that the Automation iitself does not reset once it is done so input_boolean.tropfbewasserung does not turn off again. It is not a Call Service and I also cannot reverse the Event trigger from On to Off.
At the moment it simply stays on. But what is it then?
I can trigger Event State tfor the input-boolean to on but i cannot automaticallv reset it after I am done with the irrigation. Any ideas here? I want the event State of input boolean tropfautomatik to be off again in homhe assisstant Love Lace, although the boolean beeing just a helper.

I managed lo work with try and error. Itis a call service after all. But not a switch but an input boolean.

[{"id":"cb7854fadaa73fe6","type":"api-call-service","z":"c753663a45a2236f","name":"Rasenautomatik","server":"92183824.74a3e8","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_off","areaId":[],"deviceId":[],"entityId":["input_boolean.rasenbewasserung"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":580,"y":620,"wires":[[]]},{"id":"92183824.74a3e8","type":"server","name":"Home Assistant","addon":true}]

did not know that before. Next I want to display the remainig time in Lovelace.


That’s where I’d love it to be. Shown only when the cycle is on. Right now I only have a fixed delay.
Also is there a Node to cancel the automation?