Hi! thanks for help ^^
Am trying to create node-red flow what checks computer sensor if it was off for 24 h(for day)!and then turn on switch for 4 hours.
Hi! thanks for help ^^
Am trying to create node-red flow what checks computer sensor if it was off for 24 h(for day)!and then turn on switch for 4 hours.
Two and half examples there. In the top one the switch node “either of these work” only requires one of the conditionals. Just gave an example of two that could be used.
[{"id":"5e567dbb.fcbe34","type":"inject","z":"5eb3594f.d294b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":188,"y":832,"wires":[["f3aaf68f.56e738"]]},{"id":"f3aaf68f.56e738","type":"api-get-history","z":"5eb3594f.d294b8","name":"","startdate":"","enddate":"","entityid":"switch.unraid","entityidtype":"is","useRelativeTime":true,"relativeTime":"24 hr","flatten":false,"output_type":"split","output_location_type":"msg","output_location":"payload","x":334,"y":832,"wires":[["4fabbdc5.5f14a4"]]},{"id":"4fabbdc5.5f14a4","type":"template","z":"5eb3594f.d294b8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.state}}","output":"str","x":504,"y":832,"wires":[["4a4ddded.4f4384"]]},{"id":"4a4ddded.4f4384","type":"join","z":"5eb3594f.d294b8","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":638,"y":832,"wires":[["3761101a.dfe9b"]]},{"id":"3761101a.dfe9b","type":"switch","z":"5eb3594f.d294b8","name":"either of these work","property":"payload","propertyType":"msg","rules":[{"t":"regex","v":"^((?!on).)*$","vt":"str","case":true},{"t":"jsonata_exp","v":"$not($contains(payload, \"on\"))","vt":"jsonata"}],"checkall":"true","repair":false,"outputs":2,"x":822,"y":832,"wires":[["3121094c.189906"],["3121094c.189906"]]},{"id":"e3f9bb18.eee648","type":"function","z":"5eb3594f.d294b8","name":"","func":"// stop flow if entry found with state equal to \"on\"\nif(msg.payload.find(ele => ele.state === \"on\") !== undefined) {\n return;\n}\nreturn msg;","outputs":1,"noerr":0,"x":498,"y":896,"wires":[["3121094c.189906"]]},{"id":"a42c3ee1.c5d2e","type":"api-get-history","z":"5eb3594f.d294b8","name":"","startdate":"","enddate":"","entityid":"switch.unraid","entityidtype":"is","useRelativeTime":true,"relativeTime":"24 hr","flatten":true,"output_type":"array","output_location_type":"msg","output_location":"payload","x":338,"y":896,"wires":[["e3f9bb18.eee648"]]},{"id":"30a9a0ef.c764","type":"inject","z":"5eb3594f.d294b8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":188,"y":896,"wires":[["a42c3ee1.c5d2e"]]},{"id":"3121094c.189906","type":"api-call-service","z":"5eb3594f.d294b8","name":"Unraid On","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\"switch.unraid\"}","mergecontext":"","output_location":"","output_location_type":"none","x":838,"y":896,"wires":[["f37a5d76.bcf72"]]},{"id":"790348f1.9ebfe8","type":"api-call-service","z":"5eb3594f.d294b8","name":"Unraid On","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\"switch.unraid\"}","mergecontext":"","output_location":"","output_location_type":"none","x":1142,"y":896,"wires":[[]]},{"id":"f37a5d76.bcf72","type":"delay","z":"5eb3594f.d294b8","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"hours","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":988,"y":896,"wires":[["790348f1.9ebfe8"]]}]
Thanks for great example and quick help!