|
[{"id":"7bd621699123285b","type":"function","z":"3941065dc22345fd","g":"27d271bc22ec0d21","name":"时间判断【22点0分-5点0分】","func":"// 获取当前时间\nconst now = new Date();\nconst hour = now.getHours();\nconst minute = now.getMinutes();\n\n// 计算从00:00开始的总分钟数\nconst totalMinutes = hour * 60 + minute;\nconst startMinutes = 22 * 60 + 0; // 22:0\nconst endMinutes = 5 * 60 + 0; // 5:0\n\n// 判断是否在运行时间范围内\nif (startMinutes < endMinutes) \n{\n if (totalMinutes < startMinutes || totalMinutes >= endMinutes) {\n console.log(`非跨天情况 当前时间 ${now.toLocaleTimeString()} 不在运行时间范围内(22:0-5:0)`);\n return null; // 不在运行时间内,终止流程\n }\n} \nelse \n{\n if (totalMinutes >= startMinutes || totalMinutes <= endMinutes) \n {\n console.log(`跨天情况 当前时间 ${now.toLocaleTimeString()} 在运行时间范围内(22:0-5:0)`);\n }\n else\n {\n console.log(`跨天情况 当前时间 ${now.toLocaleTimeString()} 不在运行时间范围内(22:0-5:0)`);\n return null; // 不在运行时间内,终止流程\n }\n}\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":890,"y":940,"wires":[["b3f238c5b318c3bc"]]},{"id":"0f30b3a6ab627a57","type":"BooleanLogicUltimate","z":"3941065dc22345fd","g":"27d271bc22ec0d21","name":"有人判断","payloadPropName":"payload","filtertrue":"both","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"2","topic":"result","restrictinputevaluation":false,"delayEvaluation":0,"translatorConfig":"","x":430,"y":800,"wires":[[],["f31e982bd79ce912"],[]]},{"id":"98ad1cd8710310ca","type":"api-call-service","z":"3941065dc22345fd","g":"27d271bc22ec0d21","name":"开启 - 餐厅阳台灯","server":"f3341a73.241ca8","version":7,"debugenabled":false,"action":"light.turn_on","floorId":[],"areaId":[],"deviceId":[],"entityId":["light.xiao_yang_tai_xi_ding_deng"],"labelId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"light","service":"turn_on","x":690,"y":880,"wires":[["acb3b1df267d915f"]]},{"id":"acb3b1df267d915f","type":"debug","z":"3941065dc22345fd","g":"27d271bc22ec0d21","name":"有人","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1030,"y":880,"wires":[]},{"id":"2bc4b656249e5ee1","type":"debug","z":"3941065dc22345fd","g":"27d271bc22ec0d21","name":"无人","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1030,"y":1020,"wires":[]},{"id":"f31e982bd79ce912","type":"switch","z":"3941065dc22345fd","g":"27d271bc22ec0d21","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":800,"wires":[["cce2396f3516e597"],[]]},{"id":"b3f238c5b318c3bc","type":"api-call-service","z":"3941065dc22345fd","g":"27d271bc22ec0d21","name":"关闭 - 餐厅阳台灯","server":"f3341a73.241ca8","version":7,"debugenabled":false,"action":"light.turn_off","floorId":[],"areaId":[],"deviceId":[],"entityId":["light.xiao_yang_tai_xi_ding_deng"],"labelId":[],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":false,"domain":"light","service":"turn_off","x":690,"y":1020,"wires":[["2bc4b656249e5ee1"]]},{"id":"cffd9f14c62d17c2","type":"BooleanLogicUltimate","z":"3941065dc22345fd","g":"27d271bc22ec0d21","name":"无人判断","payloadPropName":"payload","filtertrue":"both","persist":true,"sInitializeWith":"WaitForPayload","triggertopic":"trigger","outputtriggeredby":"all","inputCount":"2","topic":"result","restrictinputevaluation":false,"delayEvaluation":0,"translatorConfig":"","x":430,"y":940,"wires":[[],["557b71144b0b8002"],[]]},{"id":"557b71144b0b8002","type":"switch","z":"3941065dc22345fd","g":"27d271bc22ec0d21","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":650,"y":940,"wires":[[],["7bd621699123285b"]]},{"id":"cce2396f3516e597","type":"function","z":"3941065dc22345fd","g":"27d271bc22ec0d21","name":"时间判断【22点0分-5点0分】","func":"// 获取当前时间\nconst now = new Date();\nconst hour = now.getHours();\nconst minute = now.getMinutes();\n\n// 计算从00:00开始的总分钟数\nconst totalMinutes = hour * 60 + minute;\nconst startMinutes = 22 * 60 + 0; // 22:0\nconst endMinutes = 5 * 60 + 0; // 5:0\n\n// 判断是否在运行时间范围内\nif (startMinutes < endMinutes) \n{\n if (totalMinutes < startMinutes || totalMinutes >= endMinutes) {\n console.log(`非跨天情况 当前时间 ${now.toLocaleTimeString()} 不在运行时间范围内(22:0-5:0)`);\n return null; // 不在运行时间内,终止流程\n }\n} \nelse \n{\n if (totalMinutes >= startMinutes || totalMinutes <= endMinutes) \n {\n console.log(`跨天情况 当前时间 ${now.toLocaleTimeString()} 在运行时间范围内(22:0-5:0)`);\n }\n else\n {\n console.log(`跨天情况 当前时间 ${now.toLocaleTimeString()} 不在运行时间范围内(22:0-5:0)`);\n return null; // 不在运行时间内,终止流程\n }\n}\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":890,"y":780,"wires":[["98ad1cd8710310ca"]]},{"id":"f3341a73.241ca8","type":"server","name":"Home Assistant","addon":true}] |
|