I'm making a simple scheme that the light doesn't turn off as soon as the motion sensor stops detecting motion.
The problem is in the current state node "if lamp is OFF". If it is triggered by a timestamp1, then everything works as it should: If the lamp is on, then processing is transferred to the "trigger 30s". But if this node is triggered by "motion sensor ON" and the lamp is also turned on, then processing is transferred to "lamp turn ON".
Why?
Maybe the whole scheme is wrong?
[{"id":"33b6ff569cc20110","type":"tab","label":"Поток тест","disabled":false,"info":"","env":[]},{"id":"8b2566e66474e64a","type":"api-call-service","z":"33b6ff569cc20110","name":"lamp turn ON","server":"9055ffae.cacf6","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.lobby","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":710,"y":140,"wires":[[]]},{"id":"d1b0d90ea5dbedcb","type":"api-call-service","z":"33b6ff569cc20110","name":"lamp turn OFF","server":"9055ffae.cacf6","version":3,"debugenabled":false,"service_domain":"light","service":"turn_off","entityId":"light.lobby","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":740,"y":220,"wires":[[]]},{"id":"13d7b0ce0f759053","type":"ha-device","z":"33b6ff569cc20110","name":"motion sensor ON","server":"9055ffae.cacf6","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"inputs":0,"deviceType":"trigger","device":"f22f6ab8ee392b66d2bd80f2ffb2b5de","event":{"type":"motion","platform":"device","device_id":"f22f6ab8ee392b66d2bd80f2ffb2b5de","entity_id":"binary_sensor.0x00158d0000b3b872_occupancy","domain":"binary_sensor"},"capabilities":[],"outputProperties":[{"property":"payload","propertyType":"msg","value":"off","valueType":"str"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":150,"y":140,"wires":[["1e77671f99909a74"]]},{"id":"affb3c5867f4721e","type":"ha-device","z":"33b6ff569cc20110","name":"motion sensor OFF","server":"9055ffae.cacf6","version":0,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"inputs":0,"deviceType":"trigger","device":"f22f6ab8ee392b66d2bd80f2ffb2b5de","event":{"type":"no_motion","platform":"device","device_id":"f22f6ab8ee392b66d2bd80f2ffb2b5de","entity_id":"binary_sensor.0x00158d0000b3b872_occupancy","domain":"binary_sensor"},"capabilities":[],"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":150,"y":220,"wires":[["0c264fd372109895"]]},{"id":"0c264fd372109895","type":"trigger","z":"33b6ff569cc20110","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"30","extend":false,"overrideDelay":false,"units":"s","reset":"off","bytopic":"all","topic":"topic","outputs":1,"x":430,"y":220,"wires":[["d1b0d90ea5dbedcb"]]},{"id":"1e77671f99909a74","type":"api-current-state","z":"33b6ff569cc20110","name":"if lamp is OFF","server":"9055ffae.cacf6","version":2,"outputs":2,"halt_if":"off","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.lobby","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"off","valueType":"str"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":420,"y":80,"wires":[["8b2566e66474e64a"],["0c264fd372109895"]]},{"id":"838f4e2e1f5342de","type":"inject","z":"33b6ff569cc20110","name":"timestamp1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":130,"y":80,"wires":[["1e77671f99909a74"]]},{"id":"ae1b79bb8dbd01bf","type":"inject","z":"33b6ff569cc20110","name":"timestamp2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":150,"y":280,"wires":[["0c264fd372109895"]]},{"id":"9055ffae.cacf6","type":"server","name":"","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":""}]