Why must I inject twice?

Edit: after thinking about it more on my way to work I think I’m using the trigger note wrong and it is setting the first effect but then a millisecond later going back to the previous effect hence why I see nothing changed. I’m going to try using a wait until node

ot a weird one…

This is part of a larger flow, but pretty much I’m having it check the current settings of our TV light strip, changing it to a different effect for 10s, then changing back to the original settings.

The top flow on picture works, in that it will set the light strip to the effect of “Police Lights Solid”. It of course, wont change it back after 10 seconds becauses there not service call at the end.

The bottom flow works, but I must press inject TWICE for the effect to be changed to “Police Lights Solid”.

I’m perplexed as to why adding the indicated Set lights service call at the end, causes the first inject not to change the effect?

In the pictures debug, the first message is when I pressed inject on the top flow (effect changes). The 2nd one is pressing inject on the bottom flow (effect didnt change), the 3rd one is pressing inject AGAIN on the bottom flow (effect changes)

[{"id":"e09711f2.0032d","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"b57356e0.8e3578","type":"inject","z":"e09711f2.0032d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":178,"y":162,"wires":[["8b1065ea.4be358"]]},{"id":"49f64438.da5d9c","type":"change","z":"e09711f2.0032d","name":"Set Police Lights Solid","rules":[{"t":"set","p":"payload","pt":"msg","to":"{ \"effect\": \"Police Lights Solid\" }","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":776,"y":153,"wires":[["22ec7bbd.af41e4"]]},{"id":"22ec7bbd.af41e4","type":"api-call-service","z":"e09711f2.0032d","name":"Set lights","server":"ab3e2c53.e3491","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hyperion","data":"{{{payload}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":817,"y":198,"wires":[["9836fbe6.c1acc8","ce4de952.6c0318"]]},{"id":"9836fbe6.c1acc8","type":"trigger","z":"e09711f2.0032d","name":"Wait 10 sec","op1":"","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1024,"y":153,"wires":[["d8e3a0c4.9a18"]]},{"id":"d8e3a0c4.9a18","type":"change","z":"e09711f2.0032d","name":"","rules":[{"t":"set","p":"rgb0","pt":"msg","to":"rgb0","tot":"global"},{"t":"set","p":"rgb1","pt":"msg","to":"rgb1","tot":"global"},{"t":"set","p":"rgb2","pt":"msg","to":"rgb2","tot":"global"},{"t":"set","p":"brightness","pt":"msg","to":"brightness","tot":"global"},{"t":"set","p":"effect","pt":"msg","to":"effect","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":1062,"y":198,"wires":[[]]},{"id":"3f495cff.f905a4","type":"api-call-service","z":"e09711f2.0032d","name":"Set lights","server":"ab3e2c53.e3491","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hyperion","data":"{ \"effect\": \"{{effect}}\", \"rgb_color\": [{{rgb0}}, {{rgb1}}, {{rgb2}}], \"brightness\": {{brightness}} }","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1240,"y":414,"wires":[[]]},{"id":"8b1065ea.4be358","type":"api-current-state","z":"e09711f2.0032d","name":"TV lightstrip on?","server":"ab3e2c53.e3491","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.hyperion","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":315,"y":207,"wires":[["7ecc3d87.40d7b4"],[]]},{"id":"7ecc3d87.40d7b4","type":"api-current-state","z":"e09711f2.0032d","name":"Check current values","server":"ab3e2c53.e3491","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.hyperion","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":497,"y":153,"wires":[["b58cea80.ec0348"]]},{"id":"b58cea80.ec0348","type":"change","z":"e09711f2.0032d","name":"","rules":[{"t":"set","p":"brightness","pt":"global","to":"data.attributes.brightness","tot":"msg"},{"t":"set","p":"effect","pt":"global","to":"data.attributes.effect","tot":"msg"},{"t":"set","p":"rgb0","pt":"global","to":"data.attributes.rgb_color.0","tot":"msg"},{"t":"set","p":"rgb1","pt":"global","to":"data.attributes.rgb_color.1","tot":"msg"},{"t":"set","p":"rgb2","pt":"global","to":"data.attributes.rgb_color.2","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":603,"y":207,"wires":[["49f64438.da5d9c"]]},{"id":"6e19f99b.6a2bc8","type":"comment","z":"e09711f2.0032d","name":"This works first time, everytime. Lightstrip changes to Police Lights Solid","info":"","x":398,"y":99,"wires":[]},{"id":"a85cfcc1.fd02","type":"comment","z":"e09711f2.0032d","name":"This I must inject twice.  But looking at debug, its sending same payload as example above.  Dont get why it wont work with 1 inject","info":"","x":571,"y":342,"wires":[]},{"id":"4b7187a2.3adda8","type":"inject","z":"e09711f2.0032d","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":178,"y":405,"wires":[["81a301d3.de5ee"]]},{"id":"aa21bdde.ff7af","type":"change","z":"e09711f2.0032d","name":"Set Police Lights Solid","rules":[{"t":"set","p":"payload","pt":"msg","to":"{ \"effect\": \"Police Lights Solid\" }","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":776,"y":396,"wires":[["11f72be2.3ccb04"]]},{"id":"11f72be2.3ccb04","type":"api-call-service","z":"e09711f2.0032d","name":"Set lights","server":"ab3e2c53.e3491","version":1,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.hyperion","data":"{{{payload}}}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":817,"y":441,"wires":[["53cf75d0.dfac8c","ce4de952.6c0318"]]},{"id":"53cf75d0.dfac8c","type":"trigger","z":"e09711f2.0032d","name":"Wait 10 sec","op1":"","op2":"0","op1type":"str","op2type":"str","duration":"10","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":1024,"y":396,"wires":[["3bdc40f4.8ca35"]]},{"id":"3bdc40f4.8ca35","type":"change","z":"e09711f2.0032d","name":"","rules":[{"t":"set","p":"rgb0","pt":"msg","to":"rgb0","tot":"global"},{"t":"set","p":"rgb1","pt":"msg","to":"rgb1","tot":"global"},{"t":"set","p":"rgb2","pt":"msg","to":"rgb2","tot":"global"},{"t":"set","p":"brightness","pt":"msg","to":"brightness","tot":"global"},{"t":"set","p":"effect","pt":"msg","to":"effect","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":1062,"y":441,"wires":[["3f495cff.f905a4"]]},{"id":"81a301d3.de5ee","type":"api-current-state","z":"e09711f2.0032d","name":"TV lightstrip on?","server":"ab3e2c53.e3491","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.hyperion","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":315,"y":450,"wires":[["cff0cceb.4fb0d"],[]]},{"id":"cff0cceb.4fb0d","type":"api-current-state","z":"e09711f2.0032d","name":"Check current values","server":"ab3e2c53.e3491","version":1,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"light.hyperion","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":497,"y":396,"wires":[["ced7eb01.392a58"]]},{"id":"ced7eb01.392a58","type":"change","z":"e09711f2.0032d","name":"","rules":[{"t":"set","p":"brightness","pt":"global","to":"data.attributes.brightness","tot":"msg"},{"t":"set","p":"effect","pt":"global","to":"data.attributes.effect","tot":"msg"},{"t":"set","p":"rgb0","pt":"global","to":"data.attributes.rgb_color.0","tot":"msg"},{"t":"set","p":"rgb1","pt":"global","to":"data.attributes.rgb_color.1","tot":"msg"},{"t":"set","p":"rgb2","pt":"global","to":"data.attributes.rgb_color.2","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":603,"y":450,"wires":[["aa21bdde.ff7af"]]},{"id":"ce4de952.6c0318","type":"debug","z":"e09711f2.0032d","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1274,"y":270,"wires":[]},{"id":"ab3e2c53.e3491","type":"server","name":"AvilaSmartHomeRpi","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

I don’t use node red but the first thing I would do is try these service calls outside node red to eliminate that as a root cause.

@Petro well its hard to try it outside node red because I’m writing values to variables and then injecting them again. I mean, it works outside of node red if I manually input the values in the service calls as opposed to using variables.

And I know the “set lights” service call that I attach on to the end of the bottom flow works, as I can run it independently and it does change the lightstrip to its previous settings. I dont get why adding it, stops the first effect from working.

image

Well that’s what I mean. Run an effect, then run another effect. If it doesn’t allow that outside node-red, then it won’t allow that inside.

Using text to speech right now so please ignore the incorrect words

I can run two effects back to back outside of no red. But obviously it will only run the first effect until I call the second one.

Outside of no ride if I run the first effect wait 10 seconds and then run the second effect, the light strip responds accordingly.

In no ride I have that 10-second trigger and I can see from the time stamps it’s not trying to run the second effect for 10 seconds, so I should be seeing the first effect run for 10 seconds and I’m not. Or maybe I should use something other than a trigger to do a 10-second delay?

The problem is in the trigger node. You’re not waiting for 10 seconds with that configuration, you are sending a message immediately and another one after 10 seconds.

Replace it with a delay node or set it up like this: