Hello, I would like to pass the value of "timeout" which is defined in the "set timeout" function to the "camera" state node, in order to set the shutdown timer for the light when it is turned on. When I try to do it this way, I get an error when state is changed. Can you help me with this?
[{"id":"2436ecb6e442cdca","type":"time-range-switch","z":"66e8f946d2d274c4","name":"Night","lat":"42.664677","lon":"23.301669","startTime":"22:15","endTime":"06:55","startOffset":0,"endOffset":0,"x":1050,"y":1220,"wires":[["acd2084c1e178df0"],[]]},{"id":"b84d4a9292736038","type":"server-state-changed","z":"66e8f946d2d274c4","name":"Camera","server":"5f04c7c3.35aa98","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.luci_camera","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"{{timeout}}","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"msg","propertyType":"msg","value":"15 minuti","valueType":"str"}],"x":730,"y":1220,"wires":[["fe491601e6441f48"],[]]},{"id":"acd2084c1e178df0","type":"api-call-service","z":"66e8f946d2d274c4","name":"Camera OFF","server":"5f04c7c3.35aa98","version":5,"debugenabled":false,"domain":"light","service":"turn_off","areaId":[],"deviceId":[],"entityId":["light.luci_camera"],"data":"","dataType":"json","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1210,"y":1220,"wires":[[]]},{"id":"5f837daa088d5298","type":"inject","z":"66e8f946d2d274c4","name":"Initialize","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":760,"y":1160,"wires":[["fe491601e6441f48"]]},{"id":"fe491601e6441f48","type":"function","z":"66e8f946d2d274c4","name":"Set timeout","func":"const currentState = msg.payload;\nconst currentTime = new Date();\nvar timeout = global.get(\"timeout\") || 0;\nif (currentState) {\n const hour = currentTime.getHours();\n if (hour >= 23) {\n global.set(\"timeout\", 3);\n } else {\n global.set(\"timeout\", 1);\n }\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":890,"y":1220,"wires":[["2436ecb6e442cdca"]]},{"id":"5f04c7c3.35aa98","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false}]