# From Blockly to Node-RED: migration of irrigation flow

**URL:** <https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047>\
**Category:** General\
**Created:** [12 March 2020 18:58 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047 "2020-03-12T18:58:11Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmartens](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@cmartens](https://discourse.nodered.org/u/cmartens)\
**Post date:** [12 March 2020 18:58 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/1 "2020-03-12T18:58:11Z")

</div>

Hi all, in Domoticz Blockly I have defined the following Blockly (see below). However, I want to migrate this to Node-RED in Home Assistant.

This function is triggered when a switch (beregening handmatig) is switched on and one of the predefined values (Off (= Uit), 30, 60 or 90 minutes) is selected. During the selected time period, another switch (beregeningspomp) is switched on. After this time period this switch (beregeningspomp) is switched off. Besides that, it is possible to stop the program when running by putting the switch (beregening handmatig) to ‘uit’.

 ![Afbeelding1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5dbbb697e1d8bae34c1de542299fe24a555b1c01.png)

At this moment, I have added a ‘input\_select’ switch to Lovelace. I can put this switch to the predefined values.

 ![Schermafbeelding 2020-03-12 om 19.30.07](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/3752b651b8850f46b3ea4a7e58c0b41068a815c5.png)

I am looking for a solution to migrate this flow to Node-RED. I have a couple of questions:

- How can I use the input\_select switch in Node-RED as trigger?
- How can I add the predefined time periods to Node-RED, so that the pump is only switched on during the predefined time period.
- How can I add an override function, so that I can stop the flow during execution?

Thanks in advance for your support!

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [13 March 2020 08:40 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/2 "2020-03-13T08:40:19Z")

</div>

I don't use home assistant, so don't know how your "beregeningspomp" is turned on, but I think the complete flow could be easily moved to node-red (without the need of homeassistant) and I would control it via node-red-dashboard where needed (or even homekit if you use an i-device).

In dashboard you would get something like

 ![Screenshot 2020-03-13 at 09.37.36](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/c/ac36da1aa44c43be93e6dd698145a829aadc0869.jpeg)  
 ![Screenshot 2020-03-13 at 09.44.59](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f6e85d1f29d16f7d6a3bf90f52aad48d950766fd.jpeg)

And the flow, when the pulldown is changed, all triggers are reset and new timer is set (or off)

 ![Screenshot 2020-03-13 at 09.39.58](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/3/7372d9c08d0139a3567b16692063033022a3aa11.jpeg)

---

<div class="post-metadata">

**Author:** ![cmartens](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@cmartens](https://discourse.nodered.org/u/cmartens)\
**Post date:** [13 March 2020 19:19 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/3 "2020-03-13T19:19:11Z")

</div>

Hi,

I have spend more time to convert the flow. However, based on your info this was a lot easier. Below you can see the current version which is working. Thanks!

 ![Schermafbeelding 2020-03-13 om 20.08.13](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/02dbdf2617d646f2094569b8371857dbababb008.png)

I have not used the dropdown node, because I want to have the selection button displayed in Home Assistant. This switch is called "beregeningsduur".

The only thing which is not working yet, is the reset function. When I select one of the options (30, 60 or 90), the pump "beregeningspomp" is enabled during 30, 60 or 90 minutes. However, when I want to disable the function during the execution (e.g. when I have selected 30 but I had to choose 60), I can put the selector switch to "Uit" (off). The pump is switched off. When I select 60 after that, the pump is switched on again. The only problem is that the "delay 30" is not stopped yet, so within 30 minutes the pump is switched off again, which is not OK.

I have tried to change the delay nodes by trigger nodes and have added a change node which converts the msg.payload to msg.reset, to be able to switch off the trigger nodes, but that is not working yet.

Do you know how to handle this? Thanks in advance for your reaction.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [13 March 2020 19:58 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/4 "2020-03-13T19:58:58Z")

</div>

> The only thing which is not working yet, is the reset function.

The reason is because you use "delay" nodes, you don't need delays, but triggers. Delays are for "sliding windows", triggers are for triggering. (note that I use delay nodes to send the reset message first followed by the message for the trigger)

See example flow:

```auto
[{"id":"ee3863a5.7d7338","type":"debug","z":"f4c451b9.1e4b1","name":"Pomp Uit","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":636,"y":264,"wires":[]},{"id":"65ab1ac1.24ab1c","type":"switch","z":"f4c451b9.1e4b1","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Off","vt":"str"},{"t":"eq","v":"30","vt":"num"},{"t":"eq","v":"60","vt":"num"},{"t":"eq","v":"90","vt":"num"}],"checkall":"true","repair":false,"outputs":4,"x":386,"y":384,"wires":[["ee3863a5.7d7338","757de5ac.42d994"],["757de5ac.42d994","94245960.3b3878"],["757de5ac.42d994","330ee386.cb3a6c"],["757de5ac.42d994","31840901.ddc2b6"]]},{"id":"c69254dc.1bd42","type":"trigger","z":"f4c451b9.1e4b1","op1":"","op2":"Off","op1type":"pay","op2type":"str","duration":"30","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":886,"y":336,"wires":[["f6525791.e1bde8"]]},{"id":"9b936561.60bcc","type":"trigger","z":"f4c451b9.1e4b1","op1":"","op2":"Off","op1type":"pay","op2type":"str","duration":"60","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":886,"y":384,"wires":[["f6525791.e1bde8"]]},{"id":"475d4281.d01f1c","type":"trigger","z":"f4c451b9.1e4b1","op1":"","op2":"Off","op1type":"pay","op2type":"str","duration":"90","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":886,"y":432,"wires":[["f6525791.e1bde8"]]},{"id":"757de5ac.42d994","type":"change","z":"f4c451b9.1e4b1","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":656,"y":480,"wires":[["c69254dc.1bd42","9b936561.60bcc","475d4281.d01f1c"]]},{"id":"94245960.3b3878","type":"delay","z":"f4c451b9.1e4b1","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":591,"y":336,"wires":[["c69254dc.1bd42"]],"l":false},{"id":"330ee386.cb3a6c","type":"delay","z":"f4c451b9.1e4b1","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":591,"y":384,"wires":[["9b936561.60bcc"]],"l":false},{"id":"31840901.ddc2b6","type":"delay","z":"f4c451b9.1e4b1","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":591,"y":432,"wires":[["475d4281.d01f1c"]],"l":false},{"id":"f6525791.e1bde8","type":"debug","z":"f4c451b9.1e4b1","name":"Pomp Aan","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1198,"y":384,"wires":[]},{"id":"ba7021fd.0847e8","type":"inject","z":"f4c451b9.1e4b1","name":"","topic":"","payload":"30","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":360,"wires":[["65ab1ac1.24ab1c"]]},{"id":"f91a89ef.d9eaa8","type":"inject","z":"f4c451b9.1e4b1","name":"","topic":"","payload":"60","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":408,"wires":[["65ab1ac1.24ab1c"]]},{"id":"9a83fd40.d1fa1","type":"inject","z":"f4c451b9.1e4b1","name":"","topic":"","payload":"90","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":456,"wires":[["65ab1ac1.24ab1c"]]},{"id":"ebf14e6b.d4f5e","type":"inject","z":"f4c451b9.1e4b1","name":"","topic":"","payload":"Off","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":312,"wires":[["65ab1ac1.24ab1c"]]}]

```

---

<div class="post-metadata">

**Author:** ![cmartens](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@cmartens](https://discourse.nodered.org/u/cmartens)\
**Post date:** [16 March 2020 10:26 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/5 "2020-03-16T10:26:06Z")

</div>

Hi, I have updated the flow and replaced the 'delay nodes' by 'trigger nodes'. Besides that, I have updated the 'change node'. It is working now! If you still see any possibilities to optimise this flow, please let me know.

To make sure that other people can use this flow, I have attached the detailed configuration.

 ![Schermafbeelding 2020-03-16 om 10.56.58](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/3/f367b375b4a905bed4362fba64d209fc70008f11.png)

To create a selection switch for setting the duration time for the “beregening handmatig” function, the following code needs to be added to configuration.yaml:

```auto
beregening_handmatig:
    name: Duur Handmatige Beregening
    options:
      - Uit
      - 30 minuten
      - 60 minuten
      - 90 minuten
    initial: Uit

```

Node-RED configuration:

- Events state: Beregeningsduur: Uit? / 30 min? / 60 min? / 90 min?

- Switch

- Call Service: Beregeningspomp: Uit

- Call Service: Beregeningspomp: Aan (3x)

- Change Node: Reset

- Trigger: 30 min / 60 min / 90 min

- Call Service: Beregeningspomp: Uit

- Call Service: Beregeningsduur: Uit

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 March 2020 13:56 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/6 "2020-03-16T13:56:21Z")

</div>

> [@cmartens](#):
>
> Besides that, I have updated the 'change node'. It is working now!

I think you might end up with race conditions, as you do not decide which message arrives quicker, the reset or the message from the "Beregeningspomp" (which I why used additional delay nodes to get the reset first, followed by the trigger).

Also do you need 4 \* Beregeningspomp nodes, cannot not reuse them ?  
And you should be able to connect only a single "Beregeningsduur" from home assistant and filter for the value.

---

<div class="post-metadata">

**Author:** ![cmartens](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@cmartens](https://discourse.nodered.org/u/cmartens)\
**Post date:** [16 March 2020 14:29 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/7 "2020-03-16T14:29:44Z")

</div>

I don’t understand what you mean with race conditions and what exactly can go wrong. Can you please explain what you mean? Or give me an example.

Do I need to add delays just before the triggers to prevent this issue?

Do you know a way how I can filter beregeningsduur based on the selection so that I don’t need to add this four times?

Thanks in advance for your help.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 March 2020 16:56 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/8 "2020-03-16T16:56:10Z")

</div>

Ik doe het even in het Nederlands  
Ik ben niet thuis in home assistant zoals gezegd, alles in node-red 😉

Maar die "Beregeningsduur" homeassistant node, kun je daar niet direct de opties van uitlezen (zonder er 4 te hoeven gebruiken) ?

Voor de "Beregeningspomp" node, die zijn allemaal hetzelfde toch ? Daar kun je er ook 1 van maken en die doorsturen naar de trigger (of delay -\> trigger).

Zou je je flow kunnen posten, dan kan ik wat beter zien waar je naar toe werkt.

---

<div class="post-metadata">

**Author:** ![cmartens](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@cmartens](https://discourse.nodered.org/u/cmartens)\
**Post date:** [16 March 2020 17:48 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/9 "2020-03-16T17:48:36Z")

</div>

Hi, ik werk nog maar drie weken met Node-RED, kan dus nog genoeg leren. Ik weet niet of de beregeningsduur omgezet kan worden naar één node, maar ik begrijp dat dat de flow wel vereenvoudigt. Ik ben benieuwd naar de mogelijkheden.

De 'beregeningspomp: Aan' zijn inderdaad allemaal hetzelfde en zorgen ervoor dat de pomp wordt aangezet.

Hieronder de flow:

```auto
[{"id":"de88e96c.433c7","type":"tab","label":"Beregening","disabled":false,"info":""},{"id":"7d20aaa.73ed054","type":"switch","z":"de88e96c.433c7","name":"Switch","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"Uit","vt":"str"},{"t":"eq","v":"30 minuten","vt":"str"},{"t":"eq","v":"60 minuten","vt":"str"},{"t":"eq","v":"90 minuten","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":350,"y":210,"wires":[["7911543f.296774"],["6c029897.9d6ca"],["406a4b93.482b24"],["81612243.4b5aa8"]]},{"id":"10fea9aa.bf56de","type":"server-state-changed","z":"de88e96c.433c7","name":"Beregeningsduur: Uit?","server":"ab0c7805.ea8858","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_select.beregening_handmatig","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"Uit","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":160,"y":120,"wires":[["7d20aaa.73ed054"],[]]},{"id":"6c029897.9d6ca","type":"api-call-service","z":"de88e96c.433c7","name":"Beregeningspomp: Aan","server":"ab0c7805.ea8858","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"switch.fibaro_fgs222_beregeningspomp","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":550,"y":180,"wires":[["8c7ad2fc.317e7"]]},{"id":"b7c32034.6c03b","type":"server-state-changed","z":"de88e96c.433c7","name":"Beregeningsduur: 30 min?","server":"ab0c7805.ea8858","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_select.beregening_handmatig","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"30 minuten","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":150,"y":180,"wires":[["7d20aaa.73ed054"],[]]},{"id":"1e78af24.05b219","type":"server-state-changed","z":"de88e96c.433c7","name":"Beregeningsduur 60 min?","server":"ab0c7805.ea8858","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_select.beregening_handmatig","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"60 minuten","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":150,"y":240,"wires":[["7d20aaa.73ed054"],[]]},{"id":"c2f169b8.0a6008","type":"server-state-changed","z":"de88e96c.433c7","name":"Beregeningsduur 90 min?","server":"ab0c7805.ea8858","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_select.beregening_handmatig","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"90 minuten","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":150,"y":300,"wires":[["7d20aaa.73ed054"],[]]},{"id":"406a4b93.482b24","type":"api-call-service","z":"de88e96c.433c7","name":"Beregeningspomp: Aan","server":"ab0c7805.ea8858","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"switch.fibaro_fgs222_beregeningspomp","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":550,"y":240,"wires":[["e6f6797a.45d53"]]},{"id":"81612243.4b5aa8","type":"api-call-service","z":"de88e96c.433c7","name":"Beregeningspomp: Aan","server":"ab0c7805.ea8858","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"switch.fibaro_fgs222_beregeningspomp","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":550,"y":300,"wires":[["e0f6584e.6dcac8"]]},{"id":"7911543f.296774","type":"api-call-service","z":"de88e96c.433c7","name":"Beregeningspomp: Uit","server":"ab0c7805.ea8858","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_off","entityId":"switch.fibaro_fgs222_beregeningspomp","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":540,"y":120,"wires":[["439b69da.1fbe"]]},{"id":"cab977a1.5fb678","type":"comment","z":"de88e96c.433c7","name":"Beregening Handmatig","info":"","x":140,"y":60,"wires":[]},{"id":"732594f6.c76a5c","type":"api-call-service","z":"de88e96c.433c7","name":"Beregeningspomp: Uit","server":"ab0c7805.ea8858","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_off","entityId":"switch.fibaro_fgs222_beregeningspomp","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":960,"y":210,"wires":[[]]},{"id":"d3517ad5.e261a8","type":"api-call-service","z":"de88e96c.433c7","name":"Beregeningsduur: Uit","server":"ab0c7805.ea8858","version":1,"debugenabled":false,"service_domain":"input_select","service":"select_option","entityId":"input_select.beregening_handmatig","data":"{\"option\": \"Uit\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":960,"y":269,"wires":[[]]},{"id":"439b69da.1fbe","type":"change","z":"de88e96c.433c7","name":"Reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":750,"y":120,"wires":[["8c7ad2fc.317e7","e6f6797a.45d53","e0f6584e.6dcac8"]]},{"id":"8c7ad2fc.317e7","type":"trigger","z":"de88e96c.433c7","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"30","extend":false,"units":"min","reset":"","bytopic":"all","name":"30 min","x":750,"y":180,"wires":[["732594f6.c76a5c","d3517ad5.e261a8"]]},{"id":"e6f6797a.45d53","type":"trigger","z":"de88e96c.433c7","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"60","extend":false,"units":"min","reset":"","bytopic":"all","name":"60 min","x":750,"y":240,"wires":[["732594f6.c76a5c","d3517ad5.e261a8"]]},{"id":"e0f6584e.6dcac8","type":"trigger","z":"de88e96c.433c7","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"90","extend":false,"units":"min","reset":"","bytopic":"all","name":"90 min","x":750,"y":300,"wires":[["732594f6.c76a5c","d3517ad5.e261a8"]]},{"id":"ab0c7805.ea8858","type":"server","z":"","name":"Home Assistant","addon":true}]

```

Nogmaals bedankt voor het meedenken!

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 March 2020 18:03 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/10 "2020-03-16T18:03:01Z")

</div>

Sluit eens een debug node aan op 1 van die "beregeningsduur:x" nodes, wat is de output daarvan als je de pulldown veranderd in home assistant ?

---

<div class="post-metadata">

**Author:** ![cmartens](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@cmartens](https://discourse.nodered.org/u/cmartens)\
**Post date:** [16 March 2020 18:35 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/11 "2020-03-16T18:35:19Z")

</div>

Dit is het resultaat:

![Schermafbeelding 2020-03-16 om 19.34.42](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/a/2a1b89dddf184cd6d0ffd8466f8306ac480fcf1c.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 March 2020 18:51 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/12 "2020-03-16T18:51:47Z")

</div>

En als je m veranderd naar “60 minuten” dan krijg je “60 minuten”?

en wat voor input verwacht "Beregeningspomp" ?

Probeer deze flow:

```auto
[{"id":"14402736.425229","type":"trigger","z":"e7da55c7.1c95b","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"30","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":550,"y":336,"wires":[["e16f2fd5.53fbe"]]},{"id":"9bdc55d5.42ddd8","type":"trigger","z":"e7da55c7.1c95b","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"60","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":550,"y":384,"wires":[["e16f2fd5.53fbe"]]},{"id":"9308e26e.31542","type":"trigger","z":"e7da55c7.1c95b","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"90","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":550,"y":432,"wires":[["e16f2fd5.53fbe"]]},{"id":"b8108a64.a5bfe8","type":"switch","z":"e7da55c7.1c95b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"uit","vt":"str"},{"t":"cont","v":"30","vt":"str"},{"t":"cont","v":"60","vt":"str"},{"t":"cont","v":"90","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":303,"y":384,"wires":[["1ce435f9.2297ea"],["1ce435f9.2297ea","8bc20b12.ce9e58"],["9bdc55d5.42ddd8","1ce435f9.2297ea"],["1ce435f9.2297ea","d1400d23.af46e8"]],"l":false},{"id":"1ce435f9.2297ea","type":"change","z":"e7da55c7.1c95b","name":"reset trigger","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":399,"y":288,"wires":[["14402736.425229","9bdc55d5.42ddd8","9308e26e.31542"]],"l":false},{"id":"f4900389.3d259","type":"change","z":"e7da55c7.1c95b","name":"uit","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"option\": \"Uit\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":408,"wires":[[]]},{"id":"ae0c9a66.89b4b","type":"comment","z":"e7da55c7.1c95b","name":"van HA: beregeningsduur","info":"","x":158,"y":384,"wires":[]},{"id":"606368cf.7b5b5","type":"comment","z":"e7da55c7.1c95b","name":"naar HA: Beregeningspomp","info":"","x":984,"y":384,"wires":[]},{"id":"e16f2fd5.53fbe","type":"switch","z":"e7da55c7.1c95b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":663,"y":384,"wires":[["1a62be81.7fca79"],["f4900389.3d259"]],"l":false},{"id":"1a62be81.7fca79","type":"change","z":"e7da55c7.1c95b","name":"Aan","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"option\": \"Aan\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":770,"y":360,"wires":[[]]},{"id":"8bc20b12.ce9e58","type":"delay","z":"e7da55c7.1c95b","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":399,"y":336,"wires":[["14402736.425229"]],"l":false},{"id":"9742c58a.66be78","type":"delay","z":"e7da55c7.1c95b","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":399,"y":384,"wires":[[]],"l":false},{"id":"d1400d23.af46e8","type":"delay","z":"e7da55c7.1c95b","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":399,"y":432,"wires":[["9308e26e.31542"]],"l":false}]

```

Dan hoef je alleen:

- 1x Beregeningsduur aan het begin en
- 1x Beregeningspomp aan het eind vast te maken

Maar goed ik weet niet hoe die pomp uit gaat in home assistant en wat voor data hij daar voor nodig heeft.

---

<div class="post-metadata">

**Author:** ![cmartens](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@cmartens](https://discourse.nodered.org/u/cmartens)\
**Post date:** [16 March 2020 20:35 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/13 "2020-03-16T20:35:55Z")

</div>

Bedankt voor je reactie!

Als ik de switch op 60 minuten zet, dan geeft deze inderdaad '60 minuten door'. Ik heb de flow getest en de meeste functies werken prima. Alleen de reset functie werkt niet. De msg.reset komt wel binnen bij de trigger, deze wordt gereset. Alleen gebeurt er verder niets meer. Ik heb een debug node toegevoegd achter de trigger node. Bij een reset gebeurt er niet. Weet je hier nog een oplossing voor?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 March 2020 20:45 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/14 "2020-03-16T20:45:01Z")

</div>

De switch node is case-senstive, ging niet helemaal goed.

Probeer dit, deze flow werkt (al de inject nodes kun je vervangen met de enkele beregenings duur). Komt er dan uit wat je nodig hebt (uit de debug node)?

```auto
[{"id":"b668bf08.9ccb28","type":"debug","z":"e7da55c7.1c95b","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":890,"y":648,"wires":[]},{"id":"a8634b8b.ad44c8","type":"trigger","z":"e7da55c7.1c95b","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"30","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":502,"y":600,"wires":[["3029c32b.71cad4"]]},{"id":"260df08e.68ddc8","type":"trigger","z":"e7da55c7.1c95b","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"60","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":502,"y":648,"wires":[["3029c32b.71cad4"]]},{"id":"b76483ef.95aae","type":"trigger","z":"e7da55c7.1c95b","op1":"true","op2":"false","op1type":"bool","op2type":"bool","duration":"90","extend":false,"units":"min","reset":"","bytopic":"all","name":"","x":502,"y":696,"wires":[["3029c32b.71cad4"]]},{"id":"60c990e8.f49288","type":"switch","z":"e7da55c7.1c95b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"cont","v":"Uit","vt":"str"},{"t":"cont","v":"30","vt":"str"},{"t":"cont","v":"60","vt":"str"},{"t":"cont","v":"90","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":255,"y":648,"wires":[["f0c74c5e.a72f08","8d7e6874.530d98"],["f0c74c5e.a72f08","7283ab91.7103ac"],["260df08e.68ddc8","f0c74c5e.a72f08"],["f0c74c5e.a72f08","297538b.3031ac8"]],"l":false},{"id":"f0c74c5e.a72f08","type":"change","z":"e7da55c7.1c95b","name":"reset trigger","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":351,"y":552,"wires":[["a8634b8b.ad44c8","260df08e.68ddc8","b76483ef.95aae"]],"l":false},{"id":"8d7e6874.530d98","type":"change","z":"e7da55c7.1c95b","name":"uit","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"option\": \"Uit\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":722,"y":672,"wires":[["b668bf08.9ccb28"]]},{"id":"3029c32b.71cad4","type":"switch","z":"e7da55c7.1c95b","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":615,"y":648,"wires":[["2fda1427.713aa4"],["8d7e6874.530d98"]],"l":false},{"id":"2fda1427.713aa4","type":"change","z":"e7da55c7.1c95b","name":"Aan","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"option\": \"Aan\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":722,"y":624,"wires":[["b668bf08.9ccb28"]]},{"id":"7283ab91.7103ac","type":"delay","z":"e7da55c7.1c95b","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":351,"y":600,"wires":[["a8634b8b.ad44c8"]],"l":false},{"id":"2dde87af.6cef28","type":"delay","z":"e7da55c7.1c95b","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":351,"y":648,"wires":[[]],"l":false},{"id":"297538b.3031ac8","type":"delay","z":"e7da55c7.1c95b","name":"","pauseType":"delay","timeout":"250","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":351,"y":696,"wires":[["b76483ef.95aae"]],"l":false},{"id":"d869f7f0.efe87","type":"inject","z":"e7da55c7.1c95b","name":"","topic":"","payload":"30 minuten","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":108,"y":624,"wires":[["60c990e8.f49288"]]},{"id":"5fc2b274.8f52f4","type":"inject","z":"e7da55c7.1c95b","name":"","topic":"","payload":"60 minuten","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":108,"y":672,"wires":[["60c990e8.f49288"]]},{"id":"48f0c89c.adba58","type":"inject","z":"e7da55c7.1c95b","name":"","topic":"","payload":"90 minuten","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":108,"y":720,"wires":[["60c990e8.f49288"]]},{"id":"9e7226f8.a54e58","type":"inject","z":"e7da55c7.1c95b","name":"","topic":"","payload":"Uit","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":98,"y":576,"wires":[["60c990e8.f49288"]]}]

```

---

<div class="post-metadata">

**Author:** ![cmartens](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@cmartens](https://discourse.nodered.org/u/cmartens)\
**Post date:** [16 March 2020 21:51 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/15 "2020-03-16T21:51:30Z")

</div>

Het werkt nu! Super blij mee! Dankjewel! Hieronder het eindresultaat:

 ![Schermafbeelding 2020-03-16 om 22.38.58](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/e/1e53b2eb73157541f1aea28751df3eeb2c7cc640.png)

Events state: Beregeningsduur:

- Server: Home Assistant

- Entity ID: input\_select.beregening\_handmatig

- If State: is

- ‘Tweede veld van If State leeg laten’

- Enable ‘Output only on state change’

Switch

- == 30 minuten  1

- == 60 minuten  2

- == 90 minuten  3

- == Uit  4

Delay (3x)

- Action: Delay each message

- Fixed delay

- For 250 milliseconds

Change Node: Reset

- Set msg.reset to true

Trigger: 30 min / 60 min / 90 min

- Send: true

- Then wait for

- 30 minutes / 60 minutes / 90 minutes

- Then send false

- Handling: all messages

Switch

- == true  1

- == false  2

Change Node: Aan

- Set msg.payload

- To: {"option": "Aan"}

Change Node: Uit

- Set msg.payload

- To: {"option": "Uit"}

Call Service: Pomp: Aan

- Server: Home Assistant

- Domain: homeassistant

- Service: turn\_on

- Entity ID: switch.fibaro\_fgs222\_beregeningspomp

Call Service: Pomp: Uit

- Server: Home Assistant

- Domain: homeassistant

- Service: turn\_off

- Entity ID: switch.fibaro\_fgs222\_beregeningspomp

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [16 March 2020 22:28 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/16 "2020-03-16T22:28:43Z")

</div>

Nice!

Denk dat je ook nog een pomp:aan/uit kan verwijderen. En die aan/uit beide naar die enkele node, ligt er een beetje aan wat die node verwacht qua input.

---

<div class="post-metadata">

**Author:** ![cmartens](https://avatars.discourse-cdn.com/v4/letter/c/b5e925/32.png) [@cmartens](https://discourse.nodered.org/u/cmartens)\
**Post date:** [18 March 2020 19:43 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/17 "2020-03-18T19:43:06Z")

</div>

Hi, next step is to build a flow for automatic irrigation. On a predefined start-time, the pump will start. Based on a input\_number in home assistant's configuration.yaml, I have build a way to set the duration in minutes (see below). I would like to enable the pump during this duration. After this, the pump needs to switch off again.

 ![Schermafbeelding 2020-03-18 om 20.41.42](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/7/87eae214f50a5f37f5b939be97693fad60d13317.png)

I have read different articles on the internet how to deal with this. Based on that, I have build the attached flow. However it doesn't work. The pump goes on, however will not go off after the defined duration. Can anybody help me? Thanks.

```auto
[{"id":"38a25e3d.997a72","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"6b5434bf.abd75c","type":"api-call-service","z":"38a25e3d.997a72","name":"Tuinverlichting: Aan","server":"ab0c7805.ea8858","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"switch.tuinverlichting","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":450,"y":240,"wires":[["105934d6.c77223"]]},{"id":"9bfacdd8.e4d2d","type":"bigtimer","z":"38a25e3d.997a72","outtopic":"","outpayload1":"On","outpayload2":"Off","name":"Big Timer","comment":"","lat":"51.766547","lon":"5.578379","starttime":"1230","endtime":"10001","starttime2":0,"endtime2":0,"startoff":"0","endoff":0,"startoff2":0,"endoff2":0,"offs":0,"outtext1":"","outtext2":"","timeout":1440,"sun":true,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"jan":true,"feb":true,"mar":true,"apr":true,"may":true,"jun":true,"jul":true,"aug":true,"sep":true,"oct":true,"nov":true,"dec":true,"day1":0,"month1":0,"day2":0,"month2":0,"day3":0,"month3":0,"day4":0,"month4":0,"day5":0,"month5":0,"day6":0,"month6":0,"d1":0,"w1":0,"d2":0,"w2":0,"d3":0,"w3":0,"d4":0,"w4":0,"d5":0,"w5":0,"d6":0,"w6":0,"xday1":0,"xmonth1":0,"xday2":0,"xmonth2":0,"xday3":0,"xmonth3":0,"xday4":0,"xmonth4":0,"xday5":0,"xmonth5":0,"xday6":0,"xmonth6":0,"xd1":0,"xw1":0,"xd2":0,"xw2":0,"xd3":0,"xw3":0,"xd4":0,"xw4":0,"xd5":0,"xw5":0,"xd6":0,"xw6":0,"suspend":false,"random":false,"repeat":true,"atstart":true,"odd":false,"even":false,"x":120,"y":260,"wires":[["f3ec4be3.565438"],[],[]]},{"id":"f3ec4be3.565438","type":"switch","z":"38a25e3d.997a72","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"On","vt":"str"},{"t":"eq","v":"Off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":240,"wires":[["6b5434bf.abd75c"],[]]},{"id":"d976830d.f86728","type":"delay","z":"38a25e3d.997a72","name":"","pauseType":"delayv","timeout":"1","timeoutUnits":"hours","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":500,"y":380,"wires":[["c674030.13bf78"]]},{"id":"105934d6.c77223","type":"api-current-state","z":"38a25e3d.997a72","name":"","server":"5c4a405b.a230e","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"input_number.duration","state_type":"str","state_location":"","override_payload":"none","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":710,"y":240,"wires":[["db668cd9.ba8e48","d340e925.8c786"]],"outputLabels":["msg.delay"]},{"id":"bdaf9b7d.db9f","type":"change","z":"38a25e3d.997a72","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"delay","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":380,"wires":[["d976830d.f86728"]]},{"id":"db668cd9.ba8e48","type":"function","z":"38a25e3d.997a72","name":"convert time","func":"msg.payload = parseFloat(msg.payload) * 60000;\nreturn msg;","outputs":1,"noerr":0,"x":150,"y":380,"wires":[["bdaf9b7d.db9f","4c8f1409.f53edc"]]},{"id":"c674030.13bf78","type":"api-call-service","z":"38a25e3d.997a72","name":"Tuinverlichting: Uit","server":"ab0c7805.ea8858","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_off","entityId":"switch.tuinverlichting","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":670,"y":380,"wires":[[]]},{"id":"d340e925.8c786","type":"debug","z":"38a25e3d.997a72","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":800,"y":160,"wires":[]},{"id":"4c8f1409.f53edc","type":"debug","z":"38a25e3d.997a72","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":240,"y":500,"wires":[]},{"id":"ab0c7805.ea8858","type":"server","z":"","name":"Home Assistant","addon":true},{"id":"5c4a405b.a230e","type":"server","z":"","name":"Home Assistant"}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 April 2020 19:43 UTC](https://discourse.nodered.org/t/from-blockly-to-node-red-migration-of-irrigation-flow/23047/18 "2020-04-01T19:43:09Z")

</div>

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