Hello,
I only recently discovered Node-RED and use V3.0.2 with Home Assistant. I work on automating my covers depending on the sun position and the weather.
What the flow does:
- starts at a defined sun position (azimuth)
- checks the weather and decides whether it is necessary to lower the covers
- takes a list of covers
- checks whether each of those windows is already lower than the desired position
- if this is not the case, saves the current position and lowers it to the desired position
- WAITS (-> here is the problem, see below)
- sets the position of each window back to the prior position unless the position has been changed manually in the meantime
My problem is:
- I have to use the "delay" node to make the flow wait. That works, but I would rather want to wait until the sun reaches a predefined position before the covers are moved to their prior position
- If I use the "wait until" node instead, the behaviour is not what I would expect. Unlike the "delay" node, which forwards all messages (one for each cover), the "wait until" node only forwards the message for ONE cover and thus only one cover is moved to its prior position.
Is there a more elegant solution that lets the flow wait until sun.azimut reaches a predefined position and then forwards all queued messages instead of only one?
Thank you for your help!
The flow:
[{"id":"5c77e641ea8fb1b7","type":"tab","label":"Rollo Forum","disabled":true,"info":"","env":[]},{"id":"e38af58e4866faa3","type":"function","z":"5c77e641ea8fb1b7","name":"Verschattung Süd aktiv","func":"var speicher = flow.get('verschattung_sud_aktiv') || \"Nein\";\nif (speicher===\"Nein\")\n{\n flow.set('verschattung_sud_aktiv',\"Ja\");\n msg.payload=\"Ja\";\n return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1120,"y":300,"wires":[["55818be2c27c5a6e"]]},{"id":"928480982b3c4e88","type":"trigger-state","z":"5c77e641ea8fb1b7","name":"azimuth_start bis azimuth_start+3","server":"5a3777c7.b71588","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.sun_solar_azimuth","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":">=","comparatorValueDatatype":"num","comparatorValue":"130"},{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"<=","comparatorValueDatatype":"num","comparatorValue":"133"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":true,"state_type":"num","enableInput":false,"x":220,"y":300,"wires":[["68707f5eb506fd20"],[]]},{"id":"68707f5eb506fd20","type":"api-current-state","z":"5c77e641ea8fb1b7","name":"Erw. Temperatur über x","server":"5a3777c7.b71588","version":3,"outputs":2,"halt_if":"23","halt_if_type":"num","halt_if_compare":"gte","entity_id":"sensor.openweathermap_forecast_temperature","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"},{"property":"test","propertyType":"msg","value":"temperatur","valueType":"flow"}],"for":0,"forType":"num","forUnits":"minutes","x":540,"y":300,"wires":[["35568355a6d8a2f3","48e0862dbcc7ea02"],[]]},{"id":"35568355a6d8a2f3","type":"api-current-state","z":"5c77e641ea8fb1b7","name":"Wird es Sonnig?","server":"5a3777c7.b71588","version":3,"outputs":2,"halt_if":"sunny","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.openweathermap_condition","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":770,"y":260,"wires":[["e38af58e4866faa3"],[]]},{"id":"48e0862dbcc7ea02","type":"api-current-state","z":"5c77e641ea8fb1b7","name":"Wird es teilweise bedeckt?","server":"5a3777c7.b71588","version":3,"outputs":2,"halt_if":"partlycloudy","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.openweathermap_condition","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":810,"y":320,"wires":[["e38af58e4866faa3"],[]]},{"id":"c7270cdd4589d38e","type":"split","z":"5c77e641ea8fb1b7","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":300,"y":420,"wires":[["d2967c82ef6a5105"]]},{"id":"d2967c82ef6a5105","type":"change","z":"5c77e641ea8fb1b7","name":"","rules":[{"t":"set","p":"position_verschattung","pt":"msg","to":"65","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":510,"y":420,"wires":[["b38a6088a43f6d36"]]},{"id":"55818be2c27c5a6e","type":"template","z":"5c77e641ea8fb1b7","name":"Liste Rollos","field":"payload","fieldType":"msg","format":"handlebars","syntax":"plain","template":"cover.rollo_wohnen_2\ncover.rollo_wohnen_3\ncover.rollo_kids_1\ncover.rollo_schlafzimmer","output":"str","x":160,"y":420,"wires":[["c7270cdd4589d38e"]]},{"id":"b38a6088a43f6d36","type":"function","z":"5c77e641ea8fb1b7","name":"States Rollo aus Liste","func":"var states = global.get('homeassistant.homeAssistant.states');\nvar rollo = states[msg.payload];\nmsg.rollo = rollo;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":770,"y":420,"wires":[["26c11a07f216d8d5"]]},{"id":"26c11a07f216d8d5","type":"switch","z":"5c77e641ea8fb1b7","name":"Position höher (>) als position_verschattung","property":"rollo.attributes.current_position","propertyType":"jsonata","rules":[{"t":"gte","v":"position_verschattung","vt":"jsonata"},{"t":"lt","v":"position_verschattung","vt":"jsonata"}],"checkall":"true","repair":true,"outputs":2,"x":1080,"y":420,"wires":[["0fcb45bf2f12b6ab"],[]]},{"id":"5e097ee94b46ca36","type":"api-call-service","z":"5c77e641ea8fb1b7","name":"Rollo auf position_verschattung","server":"5a3777c7.b71588","version":5,"debugenabled":true,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"entity_id\": (payload),\t \"position\": (position_verschattung) \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":240,"y":480,"wires":[["757935e7ccecfa70"]]},{"id":"0fcb45bf2f12b6ab","type":"change","z":"5c77e641ea8fb1b7","name":"","rules":[{"t":"set","p":"position_vorher","pt":"msg","to":"rollo.attributes.current_position","tot":"msg","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":1390,"y":420,"wires":[["5e097ee94b46ca36"]]},{"id":"20460f22f30bce95","type":"function","z":"5c77e641ea8fb1b7","name":"States Rollo aus Liste","func":"var states = global.get('homeassistant.homeAssistant.states');\nvar rollo2 = states[msg.payload];\nmsg.rollo2 = rollo2;\n//msg.vorgaben.rollo = states[\"cover.rollo_buro_2\"];\n// var rollo = states[\"cover.rollo_buro_2\"];\n// return rollo;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":370,"y":560,"wires":[["3ba81601a5219231"]]},{"id":"3ba81601a5219231","type":"switch","z":"5c77e641ea8fb1b7","name":"Position unverändert?","property":"rollo2.attributes.current_position","propertyType":"msg","rules":[{"t":"eq","v":"position_verschattung","vt":"msg"}],"checkall":"true","repair":false,"outputs":1,"x":590,"y":560,"wires":[["d204e1c135cf267e"]]},{"id":"d204e1c135cf267e","type":"api-call-service","z":"5c77e641ea8fb1b7","name":"Rollo auf position_vorher","server":"5a3777c7.b71588","version":5,"debugenabled":true,"domain":"cover","service":"set_cover_position","areaId":[],"deviceId":[],"entityId":[],"data":"{\t \"entity_id\": (payload),\t \"position\": (position_vorher) \t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":820,"y":560,"wires":[["9666611b068d6220"]]},{"id":"757935e7ccecfa70","type":"delay","z":"5c77e641ea8fb1b7","name":"","pauseType":"delay","timeout":"6","timeoutUnits":"hours","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":170,"y":560,"wires":[["20460f22f30bce95"]]},{"id":"9666611b068d6220","type":"function","z":"5c77e641ea8fb1b7","name":"Verschattung Süd deaktiv","func":"var speicher = flow.get('verschattung_sud_aktiv') || \"Nein\";\nif (speicher===\"Ja\")\n{\n flow.set('verschattung_sud_aktiv',\"Nein\");\n msg.payload=\"Nein\";\n return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1060,"y":560,"wires":[[]]},{"id":"5a3777c7.b71588","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true}]