Subflows for generic entites

I hope that this is easy – I’m pretty new to this. I have a couple inner bulbs that don’t always turn on. I’m trying to create a loop that turns the bulbs on checks the state and continues until the bulb is on (I’m sure this is not best practice and can imagine an infinite loop – thoughts are welcome). I do this for all my Innr bulbs and thought that I could perhaps create a subflow. My problem: I don’t know how to pass the entity for each subflow and assign that entity to the service call. As an example I’d like to pass light.innr_attic_1 from the sequence calling the subflow; similarly, I would likely innr_attic_2, etc using the same subflow.

Any thoughts?

Use a loop timer node you can set how many times it retries. You can also stop it once the light is on or off

[{"id":"19ad733c.33a4d5","type":"inject","z":"9d90862d.fe487","name":"trigger","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":570,"y":320,"wires":[["3b1b0ae0.b8c476"]]},{"id":"3b1b0ae0.b8c476","type":"looptimer","z":"9d90862d.fe487","duration":"1","units":"Second","maxloops":"100","maxtimeout":"1","maxtimeoutunits":"Hour","name":"","x":780,"y":320,"wires":[["9eda04ef.399d5"],[]]},{"id":"9eda04ef.399d5","type":"api-call-service","z":"9d90862d.fe487","name":"light turn on","server":"6b1110b5.183a4","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":990,"y":320,"wires":[[]]},{"id":"be1082d3.59fa68","type":"server-state-changed","z":"9d90862d.fe487","name":"","server":"6b1110b5.183a4","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"your_light","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":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":300,"y":380,"wires":[["a8431280.bd49c8"],["68878d1.ef49674"]]},{"id":"a8431280.bd49c8","type":"change","z":"9d90862d.fe487","name":"set to stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":360,"wires":[["3b1b0ae0.b8c476"]]},{"id":"fddc53a6.35f278","type":"inject","z":"9d90862d.fe487","name":"trigger","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":550,"y":440,"wires":[["93bbe561.1744e8"]]},{"id":"93bbe561.1744e8","type":"looptimer","z":"9d90862d.fe487","duration":"1","units":"Second","maxloops":"100","maxtimeout":"1","maxtimeoutunits":"Hour","name":"","x":780,"y":440,"wires":[["e9d1c51a.80cdf8"],[]]},{"id":"e9d1c51a.80cdf8","type":"api-call-service","z":"9d90862d.fe487","name":"light turn off","server":"6b1110b5.183a4","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":990,"y":440,"wires":[[]]},{"id":"68878d1.ef49674","type":"change","z":"9d90862d.fe487","name":"set to stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":400,"wires":[["93bbe561.1744e8"]]},{"id":"6b1110b5.183a4","type":"server","name":"Home Assistant","version":1,"legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Thanks. Any thoughts on how to pass an entity object to a sub flow?

Well when you connect a debug node choose complete message object.

Now you can see everything in the message. Using a change node you can move, set, delete different parts of the message object.

Hi, you can find a solution in this post: