I just tested it with another light. I assume I have done something wrong, but the manual switch often sends a user ID. And sometimes it does not.
Any suggestions on my error?
[{"id":"6edc9969.5eadf8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"ca51857b.d33f88","type":"inject","z":"6edc9969.5eadf8","name":"","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":930,"y":220,"wires":[["8b2eb038.dde2e"]]},{"id":"8b2eb038.dde2e","type":"api-call-service","z":"6edc9969.5eadf8","name":"","server":"ea5ed475.5c5908","service_domain":"light","service":"toggle","data":"{\"entity_id\":\"light.office_main_lights\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":1100,"y":220,"wires":[[]]},{"id":"5b4d3435.08f69c","type":"trigger-state","z":"6edc9969.5eadf8","name":"Office light turned on","server":"ea5ed475.5c5908","entityid":"light.office_main_lights","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":4,"customoutputs":[{"outputId":"hp43dzgo8xl","messageType":"default","messageValue":"","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"on"},{"outputId":"t2ibsjrm5jf","messageType":"custom","messageValue":"{\"reset\": true, \"payload\": \"enable\"}","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"off"}],"outputinitially":false,"state_type":"str","x":120,"y":140,"wires":[[],[],["a42691be.fefd5","ad939540.2a9728"],["71a5a944.1ae528","e1b18931.7153e8"]]},{"id":"71a5a944.1ae528","type":"trigger-state","z":"6edc9969.5eadf8","name":"Motion?","server":"ea5ed475.5c5908","entityid":"binary_sensor.template_last_office_motion","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"ea06aae1s78","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":360,"y":260,"wires":[["8bd9e45.a16f118","e1b18931.7153e8","9a28a705.21f248"],[]]},{"id":"8bd9e45.a16f118","type":"debug","z":"6edc9969.5eadf8","name":"Light On","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":680,"y":320,"wires":[]},{"id":"e1b18931.7153e8","type":"trigger","z":"6edc9969.5eadf8","op1":"","op2":"off","op1type":"nul","op2type":"str","duration":"10","extend":true,"units":"min","reset":"","bytopic":"all","name":"","x":710,"y":120,"wires":[["9ac6b4e7.fae798","97fcf15e.c201c"]]},{"id":"9ac6b4e7.fae798","type":"debug","z":"6edc9969.5eadf8","name":"Light Off","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":860,"y":40,"wires":[]},{"id":"a42691be.fefd5","type":"switch","z":"6edc9969.5eadf8","name":"user_id null?","property":"data.event.new_state.context.user_id","propertyType":"msg","rules":[{"t":"null"}],"checkall":"true","repair":false,"outputs":1,"x":350,"y":120,"wires":[["4decaee6.cb3d1","85f0f0d8.ef85f","e76099d5.8231e8"]]},{"id":"4decaee6.cb3d1","type":"change","z":"6edc9969.5eadf8","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":530,"y":120,"wires":[["e1b18931.7153e8"]]},{"id":"85f0f0d8.ef85f","type":"change","z":"6edc9969.5eadf8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":200,"wires":[["71a5a944.1ae528","4e6cae9.f04d55"]]},{"id":"9a28a705.21f248","type":"api-call-service","z":"6edc9969.5eadf8","name":"Light On","server":"ea5ed475.5c5908","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.office_main_lights\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":660,"y":260,"wires":[[]]},{"id":"97fcf15e.c201c","type":"api-call-service","z":"6edc9969.5eadf8","name":"Light Off","server":"ea5ed475.5c5908","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.office_main_lights\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":900,"y":120,"wires":[[]]},{"id":"e76099d5.8231e8","type":"debug","z":"6edc9969.5eadf8","name":"Null","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":530,"y":40,"wires":[]},{"id":"4e6cae9.f04d55","type":"debug","z":"6edc9969.5eadf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":610,"y":200,"wires":[]},{"id":"ad939540.2a9728","type":"debug","z":"6edc9969.5eadf8","name":" Raw","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":330,"y":40,"wires":[]},{"id":"5c168e6d.d6b6f","type":"inject","z":"6edc9969.5eadf8","name":"","topic":"","payload":"enable","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":240,"wires":[["71a5a944.1ae528"]]},{"id":"6e69171c.7002a8","type":"inject","z":"6edc9969.5eadf8","name":"","topic":"","payload":"disable","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":90,"y":280,"wires":[["71a5a944.1ae528"]]},{"id":"216c99e.e7ed566","type":"trigger-state","z":"6edc9969.5eadf8","name":"light turned on","server":"ea5ed475.5c5908","entityid":"light.ground_floor_nook_lights","entityidfiltertype":"exact","debugenabled":false,"constraints":[],"constraintsmustmatch":"all","outputs":4,"customoutputs":[{"outputId":"hp43dzgo8xl","messageType":"default","messageValue":"","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"on"},{"outputId":"t2ibsjrm5jf","messageType":"custom","messageValue":"{\"reset\": true, \"payload\": \"enable\"}","comparatorPropertyType":"current_state","comparatorPropertyValue":"new_state.state","comparatorType":"is","comparatorValue":"off"}],"outputinitially":false,"state_type":"str","x":160,"y":640,"wires":[[],[],["c434a74e.729818","60a00920.702238"],["fe64604a.f37c6","d752ce7b.523a3"]]},{"id":"fe64604a.f37c6","type":"trigger-state","z":"6edc9969.5eadf8","name":"Motion?","server":"ea5ed475.5c5908","entityid":"binary_sensor.living_room_motion","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"id":"ea06aae1s78","targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"constraintsmustmatch":"all","outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","x":400,"y":760,"wires":[["14a21dd2.8cf1e2","d752ce7b.523a3","cae2242f.aa49d8"],[]]},{"id":"14a21dd2.8cf1e2","type":"debug","z":"6edc9969.5eadf8","name":"Light On","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":720,"y":820,"wires":[]},{"id":"d752ce7b.523a3","type":"trigger","z":"6edc9969.5eadf8","op1":"","op2":"off","op1type":"nul","op2type":"str","duration":"10","extend":true,"units":"s","reset":"","bytopic":"all","name":"","x":750,"y":620,"wires":[["b47d3eef.669bd","6fc6629a.40ac0c"]]},{"id":"b47d3eef.669bd","type":"debug","z":"6edc9969.5eadf8","name":"Light Off","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","x":900,"y":540,"wires":[]},{"id":"c434a74e.729818","type":"switch","z":"6edc9969.5eadf8","name":"user_id null?","property":"data.event.new_state.context.user_id","propertyType":"msg","rules":[{"t":"null"}],"checkall":"true","repair":false,"outputs":1,"x":390,"y":620,"wires":[["34a4b28a.a581be","e9fc6e32.ee0af","e917f898.7ec148"]]},{"id":"34a4b28a.a581be","type":"change","z":"6edc9969.5eadf8","name":"reset","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":620,"wires":[["d752ce7b.523a3"]]},{"id":"e9fc6e32.ee0af","type":"change","z":"6edc9969.5eadf8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"disable","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":700,"wires":[["fe64604a.f37c6","65fe702.161cb9"]]},{"id":"cae2242f.aa49d8","type":"api-call-service","z":"6edc9969.5eadf8","name":"Light On","server":"ea5ed475.5c5908","service_domain":"light","service":"turn_on","data":"{\"entity_id\":\"light.ground_floor_nook_lights\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":700,"y":760,"wires":[[]]},{"id":"6fc6629a.40ac0c","type":"api-call-service","z":"6edc9969.5eadf8","name":"Light Off","server":"ea5ed475.5c5908","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"light.ground_floor_nook_lights\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":940,"y":620,"wires":[[]]},{"id":"e917f898.7ec148","type":"debug","z":"6edc9969.5eadf8","name":"Null","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":570,"y":540,"wires":[]},{"id":"65fe702.161cb9","type":"debug","z":"6edc9969.5eadf8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":650,"y":700,"wires":[]},{"id":"60a00920.702238","type":"debug","z":"6edc9969.5eadf8","name":" Raw","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":370,"y":540,"wires":[]},{"id":"d272dd69.478d4","type":"inject","z":"6edc9969.5eadf8","name":"","topic":"","payload":"enable","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":740,"wires":[["fe64604a.f37c6"]]},{"id":"a5b3d72.0905728","type":"inject","z":"6edc9969.5eadf8","name":"","topic":"","payload":"disable","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":780,"wires":[["fe64604a.f37c6"]]},{"id":"ea5ed475.5c5908","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]