Hi, I am trying to achieve the following with a “group.water_group” entity. That group is a combination in hass of a pump and a valve. I further have 3 sprinklers (valves) (which have noting to do with that group, that group is another valve and pump). When I toggle a sprinkler I want node red to check if the group is on, if not turn it on. And then if the sprinkler is done (turned off) I want the group to return to the previous state as it was before (on or off).
To be sure: the group.water_group entity has nothing to do with the sprinkler entities. The sprinkler(s) need to “control” and check the state of the group.water_group.
And I created:
The flow:
[{"id":"cc9c5380.dc22a8","type":"server-state-changed","z":"3732525b.226766","name":"Sprinkler Links aan","server":"c6b350c5.b8b3c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.tuin_achter_sprinklers_links","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,"x":150,"y":2040,"wires":[["bdd3eefd.467d1","19e48427.ded77c"],["af88277b.b5973"]]},{"id":"4492c513.5d2c3c","type":"server-state-changed","z":"3732525b.226766","name":"Sprinkler Rechts aan","server":"c6b350c5.b8b3c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.tuin_achter_sprinklers_rechts","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,"x":160,"y":2100,"wires":[["bdd3eefd.467d1","19e48427.ded77c"],["af88277b.b5973"]]},{"id":"cdb974a0.43cc","type":"server-state-changed","z":"3732525b.226766","name":"Sprinkler Voor aan","server":"c6b350c5.b8b3c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.tuin_voor_sprinklers","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,"x":150,"y":2160,"wires":[["bdd3eefd.467d1","19e48427.ded77c"],["af88277b.b5973"]]},{"id":"bdd3eefd.467d1","type":"api-current-state","z":"3732525b.226766","name":"Water uit?","server":"c6b350c5.b8b3c","version":1,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.water_group","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":570,"y":2040,"wires":[["3c10728c.226a9e"],[]]},{"id":"2deaec4f.e5e30c","type":"api-call-service","z":"3732525b.226766","name":"Zet Water Group aan","server":"c6b350c5.b8b3c","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_on","entityId":"group.water_group","data":"","dataType":"jsonata","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":940,"y":2040,"wires":[[]]},{"id":"19e48427.ded77c","type":"ha-get-entities","z":"3732525b.226766","server":"c6b350c5.b8b3c","name":"Water Group","rules":[{"property":"entity_id","logic":"is","value":"group.water_group","valueType":"str"},{"property":"state","logic":"includes","value":"on,off","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":570,"y":2100,"wires":[["ffbeb9a7.745ae8"]]},{"id":"ffbeb9a7.745ae8","type":"function","z":"3732525b.226766","name":"transform data","func":"const payload = {};\npayload.domain = msg.payload.entity_id.split('.')[0];\npayload.service = `turn_${msg.payload.state}`;\npayload.data = { entity_id: msg.payload.entity_id };\n\n// create a blank message object with out new payload\nmsg = { payload: payload };\nreturn msg;","outputs":1,"noerr":0,"x":748,"y":2100,"wires":[["d31e4eb4.89c96"]]},{"id":"d31e4eb4.89c96","type":"join","z":"3732525b.226766","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":926,"y":2100,"wires":[["78a462fb.f74724"]]},{"id":"e1fb09f1.c7c218","type":"debug","z":"3732525b.226766","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1298,"y":2100,"wires":[]},{"id":"78a462fb.f74724","type":"change","z":"3732525b.226766","name":"","rules":[{"t":"set","p":"savedStates","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1104,"y":2100,"wires":[["e1fb09f1.c7c218"]]},{"id":"3c10728c.226a9e","type":"delay","z":"3732525b.226766","name":"","pauseType":"delay","timeout":"50","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":743,"y":2040,"wires":[["2deaec4f.e5e30c"]]},{"id":"af88277b.b5973","type":"change","z":"3732525b.226766","name":"Get Saved States","rules":[{"t":"set","p":"payload","pt":"msg","to":"savedStates","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":2160,"wires":[["dc9034bb.9986e"]]},{"id":"dc9034bb.9986e","type":"split","z":"3732525b.226766","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":758,"y":2160,"wires":[["766225df.a06afc"]]},{"id":"766225df.a06afc","type":"api-call-service","z":"3732525b.226766","name":"Restore State","server":"c6b350c5.b8b3c","version":1,"debugenabled":false,"service_domain":"homeassistant","service":"turn_{{payload}}","entityId":"group.water_group","data":"","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":916,"y":2160,"wires":[[]]},{"id":"c6b350c5.b8b3c","type":"server","name":"Home Assistant"}]
I tried multiple things to change etc. (not in the flow pasted) but I cannot find a way to get it work the way I want. What would be wrong and what do I need to change?
Thank you!