Yes, please do!
Thanks, @elfstone, looks like I simply forgot to wire the day and nigh output in the subflow.
Here is the updated version:
[{"id":"e2f79ea771014cac","type":"subflow","name":"Flux","info":"","category":"","in":[{"x":40,"y":60,"wires":[{"id":"d0d248ff9c3c9cdf"}]}],"out":[{"x":1440,"y":60,"wires":[{"id":"355aab77a1f28f1b","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","inputLabels":["any message"],"outputLabels":["Info"],"icon":"node-red-contrib-sun-position/sun-white.png"},{"id":"0962fbe8cc6ef7bd","type":"switch","z":"e2f79ea771014cac","name":"Times","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"night","vt":"str"},{"t":"eq","v":"dusk","vt":"str"},{"t":"eq","v":"dawn","vt":"str"},{"t":"eq","v":"day","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":490,"y":180,"wires":[["9f45b66901c4535e"],["ec545b23a267c011","b8d8297010775689"],["1fd17b9f356de574","8f412a5f3bd9ab17"],["8ddd9d8ea3158cf4"]]},{"id":"1fd17b9f356de574","type":"spline-curve","z":"e2f79ea771014cac","name":"dawn brightness","output_key":"payload","input_key":"payload","points":[{"x":0,"y":0},{"x":0.071,"y":0.02},{"x":0.254,"y":0.297},{"x":0.654,"y":0.877},{"x":1,"y":1}],"x":720,"y":200,"wires":[["8dd7b7cc157b67c5"]]},{"id":"ec545b23a267c011","type":"spline-curve","z":"e2f79ea771014cac","name":"dusk brightness","output_key":"payload","input_key":"payload","points":[{"x":0,"y":1},{"x":0.25,"y":0.8},{"x":0.75,"y":0.1},{"x":1,"y":0}],"x":720,"y":120,"wires":[["8dd7b7cc157b67c5"]]},{"id":"8f412a5f3bd9ab17","type":"spline-curve","z":"e2f79ea771014cac","name":"dawn temperature","output_key":"payload","input_key":"payload","points":[{"x":0,"y":0},{"x":0.1,"y":0.01},{"x":0.25,"y":0.05},{"x":0.4,"y":0.2},{"x":0.573,"y":0.6},{"x":1,"y":1}],"x":730,"y":240,"wires":[["904e1e2afcc897c1"]]},{"id":"b8d8297010775689","type":"spline-curve","z":"e2f79ea771014cac","name":"dusk temperature","output_key":"payload","input_key":"payload","points":[{"x":0,"y":1},{"x":0.019,"y":0.918},{"x":0.162,"y":0.541},{"x":0.536,"y":0.121},{"x":1,"y":0}],"x":730,"y":160,"wires":[["904e1e2afcc897c1"]]},{"id":"6c8eec59a8ad5310","type":"function","z":"e2f79ea771014cac","name":"Times of Day","func":"var newmsg = { topic: \"flux\", current: {}, times: {} };\nnewmsg.sunpos = JSON.parse(JSON.stringify(msg)).payload;\n\n//https://github.com/rdmtc/node-red-contrib-sun-position/wiki/Base-Functions#sun-times\nevalPeriod('night', newmsg, \"astronomicalDusk\", \"amateurDawn\",3600000);\nevalPeriod('dawn', newmsg, \"amateurDawn\", \"goldenHourDawnEnd\");\nevalPeriod('day', newmsg, \"goldenHourDawnEnd\", \"sunsetStart\", 0, -1800000);\nevalPeriod('dusk', newmsg, \"sunsetStart\", \"astronomicalDusk\", -1800000,3600000);\n\nreturn [newmsg,\n { \n topic: newmsg.current.name,\n payload: newmsg.current.perc\n }\n ];\n\nfunction Epoch2Human(epoch) {\n var myDate = new Date(epoch);\n return myDate.toLocaleString(\"fr-FR\");\n}\nfunction Epoch2iso(epoch) {\n var myDate = new Date(epoch);\n return myDate.toISOString();\n}\nfunction Epoch2Duration(epoch) {\n var sec_num = Math.floor(epoch / 1000)\n var hours = Math.floor(sec_num / 3600);\n var minutes = Math.floor((sec_num - (hours * 3600)) / 60);\n var seconds = sec_num - (hours * 3600) - (minutes * 60);\n\n if (hours < 10) { hours = \"0\" + hours; }\n if (minutes < 10) { minutes = \"0\" + minutes; }\n if (seconds < 10) { seconds = \"0\" + seconds; }\n return hours + ':' + minutes + ':' + seconds;\n}\nfunction evalPeriod(nme, obj, name_start, name_end, offset_start=0, offset_end=0) {\n var ret = { \n name: nme, \n hm_delta: null, \n hm_start: null, \n hm_end: null,\n ts_start: null,\n ts_end: null\n };\n ret.start = obj.sunpos.times[name_start].ts + offset_start;\n ret.end = obj.sunpos.times[name_end].ts + offset_end;\n\n // to cover range starting before midnight and ending after it.\n if (ret.start > ret.end) {\n var a;\n\n // before midnight\n if (ret.start < obj.sunpos.ts) {\n a = new Date(ret.end);\n a.setUTCDate(a.getUTCDate() + 1);\n ret.end = a.getTime();\n\n\n }\n else if (ret.end > obj.sunpos.ts) {\n a = new Date(ret.start);\n a.setUTCDate(a.getUTCDate() - 1);\n ret.start = a.getTime();\n\n }\n }\n\n ret.delta = ret.end - ret.start;\n ret.hm_delta = Epoch2Duration(ret.delta);\n ret.hm_start = Epoch2Human(ret.start);\n ret.hm_end = Epoch2Human(ret.end);\n ret.ts_start = Epoch2iso(ret.start);\n ret.ts_end = Epoch2iso(ret.end);\n\n obj.times[nme] = ret;\n if (ret.start <= obj.sunpos.ts && obj.sunpos.ts < ret.end) {\n obj.current = ret;\n obj.current.perc = (obj.sunpos.ts - ret.start) / ret.delta;\n }\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":60,"wires":[["355aab77a1f28f1b"],["0962fbe8cc6ef7bd"]]},{"id":"8dd7b7cc157b67c5","type":"range","z":"e2f79ea771014cac","minin":"0","maxin":"1","minout":"15","maxout":"100","action":"clamp","round":true,"property":"payload","name":"","x":980,"y":160,"wires":[["3091475fc030904a"]]},{"id":"904e1e2afcc897c1","type":"range","z":"e2f79ea771014cac","minin":"0","maxin":"1","minout":"2700","maxout":"6500","action":"clamp","round":true,"property":"payload","name":"","x":990,"y":200,"wires":[["2a2604373b10dddb"]]},{"id":"d0d248ff9c3c9cdf","type":"sun-position","z":"e2f79ea771014cac","name":"","positionConfig":"72018d9177e1240e","rules":[],"onlyOnChange":"true","topic":"","outputs":1,"start":"","startType":"none","startOffset":0,"startOffsetType":"num","startOffsetMultiplier":60000,"end":"","endType":"none","endOffset":0,"endOffsetType":"num","endOffsetMultiplier":60000,"x":150,"y":60,"wires":[["6c8eec59a8ad5310"]]},{"id":"8ddd9d8ea3158cf4","type":"change","z":"e2f79ea771014cac","name":"Day","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":280,"wires":[["9db8ab7a3a8ee31c"]]},{"id":"9f45b66901c4535e","type":"change","z":"e2f79ea771014cac","name":"Night","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":80,"wires":[["e07d1484bd27c46d"]]},{"id":"2a2604373b10dddb","type":"change","z":"e2f79ea771014cac","name":"Move","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"move","p":"payload","pt":"msg","to":"current.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":200,"wires":[["355aab77a1f28f1b"]]},{"id":"3091475fc030904a","type":"change","z":"e2f79ea771014cac","name":"Move","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"move","p":"payload","pt":"msg","to":"current.brightness","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":160,"wires":[["355aab77a1f28f1b"]]},{"id":"355aab77a1f28f1b","type":"join","z":"e2f79ea771014cac","name":"","mode":"custom","build":"merged","property":"current","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"12","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":1330,"y":60,"wires":[[]]},{"id":"9db8ab7a3a8ee31c","type":"junction","z":"e2f79ea771014cac","x":840,"y":280,"wires":[["904e1e2afcc897c1","8dd7b7cc157b67c5"]]},{"id":"e07d1484bd27c46d","type":"junction","z":"e2f79ea771014cac","x":840,"y":80,"wires":[["8dd7b7cc157b67c5","904e1e2afcc897c1"]]},{"id":"72018d9177e1240e","type":"position-config","name":"","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":99,"timeZoneDST":0,"stateTimeFormat":"3","stateDateFormat":"12","contextStore":""},{"id":"7e118ca8606a48b2","type":"subflow:e2f79ea771014cac","z":"76d268b99378117f","g":"09e8f85672b69e6e","name":"Flux","env":[],"x":330,"y":80,"wires":[["e03358fbb0d58292","9ef36a6101fdccfa"]],"icon":"node-red-node-suncalc/sun.png"}]
Here is a new version of the flux subflow with an updated script allowing for fixed time specification.
For example while I want to follow more or less the circadian circle to adjust the lights, I want to specify a fixed hour for the night such as 23:00 so my light slowly fade from dusk to that specified time, instead of the actuall sunset wihich during winter is way too early for me…
[{"id":"e2f79ea771014cac","type":"subflow","name":"Flux","info":"","category":"","in":[{"x":40,"y":60,"wires":[{"id":"d0d248ff9c3c9cdf"}]}],"out":[{"x":1440,"y":60,"wires":[{"id":"355aab77a1f28f1b","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","inputLabels":["any message"],"outputLabels":["Info"],"icon":"node-red-contrib-sun-position/sun-white.png"},{"id":"0962fbe8cc6ef7bd","type":"switch","z":"e2f79ea771014cac","name":"Times","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"night","vt":"str"},{"t":"eq","v":"dusk","vt":"str"},{"t":"eq","v":"dawn","vt":"str"},{"t":"eq","v":"day","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":490,"y":180,"wires":[["9f45b66901c4535e"],["ec545b23a267c011","b8d8297010775689"],["1fd17b9f356de574","8f412a5f3bd9ab17"],["8ddd9d8ea3158cf4"]]},{"id":"1fd17b9f356de574","type":"spline-curve","z":"e2f79ea771014cac","name":"dawn brightness","output_key":"payload","input_key":"payload","points":[{"x":0,"y":0},{"x":0.071,"y":0.02},{"x":0.254,"y":0.297},{"x":0.654,"y":0.877},{"x":1,"y":1}],"x":720,"y":200,"wires":[["8dd7b7cc157b67c5"]]},{"id":"ec545b23a267c011","type":"spline-curve","z":"e2f79ea771014cac","name":"dusk brightness","output_key":"payload","input_key":"payload","points":[{"x":0,"y":1},{"x":0.25,"y":0.8},{"x":0.75,"y":0.1},{"x":1,"y":0}],"x":720,"y":120,"wires":[["8dd7b7cc157b67c5"]]},{"id":"8f412a5f3bd9ab17","type":"spline-curve","z":"e2f79ea771014cac","name":"dawn temperature","output_key":"payload","input_key":"payload","points":[{"x":0,"y":0},{"x":0.1,"y":0.01},{"x":0.25,"y":0.05},{"x":0.4,"y":0.2},{"x":0.573,"y":0.6},{"x":1,"y":1}],"x":730,"y":240,"wires":[["904e1e2afcc897c1"]]},{"id":"b8d8297010775689","type":"spline-curve","z":"e2f79ea771014cac","name":"dusk temperature","output_key":"payload","input_key":"payload","points":[{"x":0,"y":1},{"x":0.019,"y":0.918},{"x":0.162,"y":0.541},{"x":0.536,"y":0.121},{"x":1,"y":0}],"x":730,"y":160,"wires":[["904e1e2afcc897c1"]]},{"id":"6c8eec59a8ad5310","type":"function","z":"e2f79ea771014cac","name":"Times of Day","func":"var newmsg = { topic: \"flux\", current: {}, times: {} };\nnewmsg.sunpos = JSON.parse(JSON.stringify(msg)).payload;\n\n//https://github.com/rdmtc/node-red-contrib-sun-position/wiki/Base-Functions#sun-times\nevalPeriod('dawn', newmsg, \"goldenHourDawnEnd\", \"amateurDawn\");\nevalPeriod('day', newmsg, \"sunsetStart\"); //sunsetStart\nevalPeriod('dusk', newmsg, \"23:00\"); //astronomicalDusk\nevalPeriod('night', newmsg); //amateurDawn\n\nreturn [newmsg,\n {\n topic: newmsg.current.name,\n payload: newmsg.current.perc\n }\n];\n\nfunction evalPeriod(nme, obj, end = null, start = null) {\n let d;\n let ret = {\n name: nme,\n hm_delta: null,\n hm_start: null,\n hm_end: null,\n ts_start: null,\n ts_end: null\n };\n ret.start = start ? ( obj.sunpos.times[start] === undefined ? Human2Epoch(start) : obj.sunpos.times[start].ts ) : Object.values(obj.times).at(-1).end;\n ret.end = end ? ( obj.sunpos.times[end] === undefined ? Human2Epoch(end) : obj.sunpos.times[end].ts ) : Object.values(obj.times).at(0).start;\n \n // to cover range starting before midnight and ending after it.\n if (ret.start > ret.end) {\n if (ret.start < obj.sunpos.ts) {\n d = new Date(ret.end);\n d.setUTCDate(d.getUTCDate() + 1);\n ret.end = d.getTime();\n } \n else if (ret.end > obj.sunpos.ts) {\n d = new Date(ret.start);\n d.setUTCDate(d.getUTCDate() - 1);\n ret.start = d.getTime();\n }\n }\n\n\n ret.delta = ret.end - ret.start;\n ret.hm_delta = Epoch2Duration(ret.delta);\n ret.hm_start = Epoch2Human(ret.start);\n ret.hm_end = Epoch2Human(ret.end);\n ret.ts_start = Epoch2iso(ret.start);\n ret.ts_end = Epoch2iso(ret.end);\n\n obj.times[nme] = ret;\n if (ret.start <= obj.sunpos.ts && obj.sunpos.ts < ret.end) {\n obj.current = ret;\n obj.current.perc = (obj.sunpos.ts - ret.start) / ret.delta;\n }\n}\nfunction Human2Epoch(human) {\n let d1 = new Date();\n let d2 = new Date(d1.toLocaleDateString() + \" \" + human);\n return d2.getTime();\n}\nfunction Epoch2Human(epoch) {\n var myDate = new Date(epoch);\n return myDate.toLocaleString(\"fr-FR\");\n}\nfunction Epoch2iso(epoch) {\n let d = new Date(epoch);\n return d.toISOString();\n}\nfunction Epoch2Duration(epoch) {\n let sec_num = Math.floor(epoch / 1000)\n let hours = Math.floor(sec_num / 3600);\n let minutes = Math.floor((sec_num - (hours * 3600)) / 60);\n let seconds = sec_num - (hours * 3600) - (minutes * 60);\n\n if (hours < 10) { hours = \"0\" + hours; }\n if (minutes < 10) { minutes = \"0\" + minutes; }\n if (seconds < 10) { seconds = \"0\" + seconds; }\n return hours + ':' + minutes + ':' + seconds;\n}","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":310,"y":60,"wires":[["355aab77a1f28f1b"],["0962fbe8cc6ef7bd"]]},{"id":"8dd7b7cc157b67c5","type":"range","z":"e2f79ea771014cac","minin":"0","maxin":"1","minout":"15","maxout":"100","action":"clamp","round":true,"property":"payload","name":"","x":980,"y":160,"wires":[["3091475fc030904a"]]},{"id":"904e1e2afcc897c1","type":"range","z":"e2f79ea771014cac","minin":"0","maxin":"1","minout":"2700","maxout":"6500","action":"clamp","round":true,"property":"payload","name":"","x":990,"y":200,"wires":[["2a2604373b10dddb"]]},{"id":"d0d248ff9c3c9cdf","type":"sun-position","z":"e2f79ea771014cac","name":"","positionConfig":"72018d9177e1240e","rules":[],"onlyOnChange":"true","topic":"","outputs":1,"start":"","startType":"none","startOffset":0,"startOffsetType":"num","startOffsetMultiplier":60000,"end":"","endType":"none","endOffset":0,"endOffsetType":"num","endOffsetMultiplier":60000,"x":150,"y":60,"wires":[["6c8eec59a8ad5310"]]},{"id":"8ddd9d8ea3158cf4","type":"change","z":"e2f79ea771014cac","name":"Day","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":280,"wires":[["9db8ab7a3a8ee31c"]]},{"id":"9f45b66901c4535e","type":"change","z":"e2f79ea771014cac","name":"Night","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":80,"wires":[["e07d1484bd27c46d"]]},{"id":"2a2604373b10dddb","type":"change","z":"e2f79ea771014cac","name":"Move","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"move","p":"payload","pt":"msg","to":"current.temperature","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":200,"wires":[["355aab77a1f28f1b"]]},{"id":"3091475fc030904a","type":"change","z":"e2f79ea771014cac","name":"Move","rules":[{"t":"delete","p":"topic","pt":"msg"},{"t":"move","p":"payload","pt":"msg","to":"current.brightness","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1130,"y":160,"wires":[["355aab77a1f28f1b"]]},{"id":"355aab77a1f28f1b","type":"join","z":"e2f79ea771014cac","name":"","mode":"custom","build":"merged","property":"current","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"12","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":1330,"y":60,"wires":[[]]},{"id":"9db8ab7a3a8ee31c","type":"junction","z":"e2f79ea771014cac","x":840,"y":280,"wires":[["904e1e2afcc897c1","8dd7b7cc157b67c5"]]},{"id":"e07d1484bd27c46d","type":"junction","z":"e2f79ea771014cac","x":840,"y":80,"wires":[["8dd7b7cc157b67c5","904e1e2afcc897c1"]]},{"id":"72018d9177e1240e","type":"position-config","name":"","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":99,"timeZoneDST":0,"stateTimeFormat":"3","stateDateFormat":"12","contextStore":""},{"id":"7e118ca8606a48b2","type":"subflow:e2f79ea771014cac","z":"76d268b99378117f","g":"09e8f85672b69e6e","name":"Flux","env":[],"x":330,"y":80,"wires":[["e03358fbb0d58292","9ef36a6101fdccfa"]],"icon":"node-red-node-suncalc/sun.png"}]
Nice!
I have just about finished an adaptation of this for my H801 WiFi RGBW aquarium lighting controller flashed with ESPHome. I’ve got the blue working the way I want during the night but still have to fine tune the red/green/blue curves for the morning/day/evening…
[{"id":"f0d97d577f05a92c","type":"switch","z":"43b31753070e19b0","name":"curve switch","property":"payload.times_of_day.active.name","propertyType":"msg","rules":[{"t":"eq","v":"night","vt":"str"},{"t":"eq","v":"morning","vt":"str"},{"t":"eq","v":"day","vt":"str"},{"t":"eq","v":"evening","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":195,"y":420,"wires":[["979e46fdd727e5d2"],["9e9035cf8099234b"],["d1e83c5e73f88951"],["8e5598c9d6c60136"]]},{"id":"66ae2ab586f841f2","type":"spline-curve","z":"43b31753070e19b0","name":"night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.1},{"x":0.25,"y":0.2},{"x":0.5,"y":0.4},{"x":0.75,"y":0.2},{"x":1,"y":0.1}],"x":590,"y":40,"wires":[["68f3c71879fc1d85"]]},{"id":"ac14849c57a5e83c","type":"spline-curve","z":"43b31753070e19b0","name":"morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.1},{"x":0.25,"y":0.2},{"x":0.5,"y":0.3},{"x":0.75,"y":0.4},{"x":1,"y":0.5}],"x":580,"y":80,"wires":[["68f3c71879fc1d85"]]},{"id":"d476ee5350fd3b39","type":"spline-curve","z":"43b31753070e19b0","name":"evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.4},{"x":0.333,"y":0.3},{"x":0.666,"y":0.2},{"x":1,"y":0.1}],"x":580,"y":160,"wires":[["68f3c71879fc1d85"]]},{"id":"4853a4c4103f38f7","type":"spline-curve","z":"43b31753070e19b0","name":"day curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.5},{"x":0.18,"y":0.55},{"x":0.33,"y":0.6},{"x":0.5,"y":0.7},{"x":0.67,"y":0.6},{"x":0.821,"y":0.55},{"x":1,"y":0.5}],"x":600,"y":120,"wires":[["68f3c71879fc1d85"]]},{"id":"68f3c71879fc1d85","type":"range","z":"43b31753070e19b0","minin":"0","maxin":"1","minout":"1","maxout":"255","action":"clamp","round":true,"property":"payload","name":"","x":780,"y":100,"wires":[["7b7d05b4b9f34f8b"]]},{"id":"bcf93a8aa7d30bc5","type":"sun-position","z":"43b31753070e19b0","name":"","positionConfig":"31826811.22a458","rules":[],"onlyOnChange":"true","topic":"","outputs":1,"start":"","startType":"none","startOffset":0,"startOffsetType":"num","startOffsetMultiplier":60000,"end":"","endType":"none","endOffset":0,"endOffsetType":"num","endOffsetMultiplier":60000,"x":150,"y":240,"wires":[["f6609b5cd420ca76"]]},{"id":"29a098afbb90bf8d","type":"range","z":"43b31753070e19b0","minin":"0","maxin":"1","minout":"0","maxout":"255","action":"clamp","round":true,"property":"payload","name":"","x":780,"y":420,"wires":[["73cb286d5b8b58c6"]]},{"id":"8fbd23f48cc0e20d","type":"range","z":"43b31753070e19b0","minin":"0","maxin":"1","minout":"0","maxout":"255","action":"clamp","round":true,"property":"payload","name":"","x":780,"y":580,"wires":[["5b72ab3f62d72eb8"]]},{"id":"67012d69669e4bbb","type":"spline-curve","z":"43b31753070e19b0","name":"green night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":1,"y":0}],"x":570,"y":360,"wires":[["29a098afbb90bf8d"]]},{"id":"701a9cb2f37a5561","type":"spline-curve","z":"43b31753070e19b0","name":"green morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":0.42,"y":0.018},{"x":0.54,"y":0.051},{"x":0.587,"y":0.101},{"x":0.817,"y":0.675},{"x":1,"y":0.85}],"x":560,"y":400,"wires":[["29a098afbb90bf8d"]]},{"id":"6c348849966d8edc","type":"spline-curve","z":"43b31753070e19b0","name":"green day curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":0.4,"y":0.973},{"x":0.5,"y":0.87},{"x":0.616,"y":0.983},{"x":1,"y":0}],"x":580,"y":440,"wires":[["29a098afbb90bf8d"]]},{"id":"4c4f2a8d9687c561","type":"spline-curve","z":"43b31753070e19b0","name":"green evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.75},{"x":0.5,"y":0.63},{"x":1,"y":0}],"x":560,"y":480,"wires":[["29a098afbb90bf8d"]]},{"id":"b41fd29cf8fe6b96","type":"spline-curve","z":"43b31753070e19b0","name":"blue night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.25},{"x":0.098,"y":0.243},{"x":0.25,"y":0.503},{"x":0.41,"y":0.753},{"x":0.593,"y":0.75},{"x":0.746,"y":0.5},{"x":0.864,"y":0.26},{"x":0.978,"y":0.25}],"x":580,"y":520,"wires":[["8fbd23f48cc0e20d"]]},{"id":"cd298379b74a0981","type":"spline-curve","z":"43b31753070e19b0","name":"blue morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":0.42,"y":0.018},{"x":0.54,"y":0.051},{"x":0.587,"y":0.101},{"x":0.817,"y":0.675},{"x":1,"y":0.85}],"x":570,"y":560,"wires":[["8fbd23f48cc0e20d"]]},{"id":"698a18314fd6d894","type":"spline-curve","z":"43b31753070e19b0","name":"blue day curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0.003,"y":0},{"x":0.25,"y":0.7},{"x":0.5,"y":0.993},{"x":0.75,"y":0.703},{"x":0.986,"y":0}],"x":580,"y":600,"wires":[["8fbd23f48cc0e20d"]]},{"id":"b92dfe56ebec0bf9","type":"spline-curve","z":"43b31753070e19b0","name":"blue evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.503,"y":0.403},{"x":0.983,"y":0.25}],"x":570,"y":640,"wires":[["8fbd23f48cc0e20d"]]},{"id":"3f86cc2e1f80d99f","type":"spline-curve","z":"43b31753070e19b0","name":"red night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":1,"y":0}],"x":580,"y":200,"wires":[["b024f6a02860eddc"]]},{"id":"d66171ee1ee1d623","type":"spline-curve","z":"43b31753070e19b0","name":"red morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":0.42,"y":0.018},{"x":0.54,"y":0.051},{"x":0.587,"y":0.101},{"x":0.817,"y":0.675},{"x":1,"y":0.85}],"x":570,"y":240,"wires":[["b024f6a02860eddc"]]},{"id":"12207795dc1f0a73","type":"spline-curve","z":"43b31753070e19b0","name":"red evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.75},{"x":0.5,"y":0.637},{"x":1,"y":0}],"x":570,"y":320,"wires":[["b024f6a02860eddc"]]},{"id":"4bc29c58a1d9107a","type":"spline-curve","z":"43b31753070e19b0","name":"red day curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":1},{"x":0.33,"y":1},{"x":0.66,"y":1},{"x":1,"y":1}],"x":580,"y":280,"wires":[["b024f6a02860eddc"]]},{"id":"b024f6a02860eddc","type":"range","z":"43b31753070e19b0","minin":"0","maxin":"1","minout":"0","maxout":"255","action":"clamp","round":true,"property":"payload","name":"","x":780,"y":260,"wires":[["ceaa91580b5e254e"]]},{"id":"e35665db7818a5bf","type":"range","z":"43b31753070e19b0","minin":"0","maxin":"1","minout":"0","maxout":"255","action":"clamp","round":true,"property":"payload","name":"","x":780,"y":740,"wires":[["327d15b9e8acc8b8"]]},{"id":"2e05a56a4b427a6a","type":"link in","z":"43b31753070e19b0","name":"Night Brightness","links":["979e46fdd727e5d2"],"x":425,"y":40,"wires":[["66ae2ab586f841f2"]]},{"id":"56b24d0edd0179cd","type":"link in","z":"43b31753070e19b0","name":"Morning Brightness","links":["9e9035cf8099234b"],"x":425,"y":80,"wires":[["ac14849c57a5e83c"]]},{"id":"7e6e54dc69b56b7d","type":"link in","z":"43b31753070e19b0","name":"Daylight Brightness","links":["d1e83c5e73f88951"],"x":425,"y":120,"wires":[["4853a4c4103f38f7"]]},{"id":"2bbd921dad6c2e6d","type":"link in","z":"43b31753070e19b0","name":"Evening Brightness","links":["8e5598c9d6c60136"],"x":425,"y":160,"wires":[["d476ee5350fd3b39"]]},{"id":"b37f50802bb36d2b","type":"link in","z":"43b31753070e19b0","name":"Night White","links":["979e46fdd727e5d2"],"x":425,"y":680,"wires":[["07a93e2506a56bf4"]]},{"id":"c79eac155c9f5885","type":"link in","z":"43b31753070e19b0","name":"Morning White","links":["9e9035cf8099234b"],"x":425,"y":720,"wires":[["7e089ec04a10ee1d"]]},{"id":"74741eaeb6f44a43","type":"link in","z":"43b31753070e19b0","name":"Daylight White","links":["d1e83c5e73f88951"],"x":425,"y":760,"wires":[["8a0e55ccb2eb515a"]]},{"id":"394249689def1e9c","type":"link in","z":"43b31753070e19b0","name":"Evening White","links":["8e5598c9d6c60136"],"x":445,"y":800,"wires":[["b5ec31986b77721e"]]},{"id":"548c688944e2ff36","type":"link in","z":"43b31753070e19b0","name":"Night Red","links":["979e46fdd727e5d2"],"x":425,"y":200,"wires":[["3f86cc2e1f80d99f"]]},{"id":"d8b1d281255232a2","type":"link in","z":"43b31753070e19b0","name":"Morning Red","links":["9e9035cf8099234b"],"x":425,"y":240,"wires":[["d66171ee1ee1d623"]]},{"id":"6061974c84f92423","type":"link in","z":"43b31753070e19b0","name":"Daylight Red","links":["d1e83c5e73f88951"],"x":425,"y":280,"wires":[["4bc29c58a1d9107a"]]},{"id":"c0b215245a19aaf9","type":"link in","z":"43b31753070e19b0","name":"Evening Red","links":["8e5598c9d6c60136"],"x":425,"y":320,"wires":[["12207795dc1f0a73"]]},{"id":"aec9c78a3fe08029","type":"link in","z":"43b31753070e19b0","name":"Night Green","links":["979e46fdd727e5d2"],"x":425,"y":360,"wires":[["67012d69669e4bbb"]]},{"id":"76b17055d5724e42","type":"link in","z":"43b31753070e19b0","name":"Morning Green","links":["9e9035cf8099234b"],"x":425,"y":400,"wires":[["701a9cb2f37a5561"]]},{"id":"3f51c6245a0dd3cb","type":"link in","z":"43b31753070e19b0","name":"Daylight Green","links":["d1e83c5e73f88951"],"x":425,"y":440,"wires":[["6c348849966d8edc"]]},{"id":"6b1d3103fddafb33","type":"link in","z":"43b31753070e19b0","name":"Evening Green","links":["8e5598c9d6c60136"],"x":425,"y":480,"wires":[["4c4f2a8d9687c561"]]},{"id":"2bc4e6effb057af2","type":"link in","z":"43b31753070e19b0","name":"Night Green","links":["979e46fdd727e5d2"],"x":425,"y":520,"wires":[["b41fd29cf8fe6b96"]]},{"id":"d220fb70f771e1bb","type":"link in","z":"43b31753070e19b0","name":"Morning Green","links":["9e9035cf8099234b"],"x":425,"y":560,"wires":[["cd298379b74a0981"]]},{"id":"642dcd9eaa082558","type":"link in","z":"43b31753070e19b0","name":"Daylight Green","links":["d1e83c5e73f88951"],"x":425,"y":600,"wires":[["698a18314fd6d894"]]},{"id":"c75046571506c876","type":"link in","z":"43b31753070e19b0","name":"Evening Green","links":["8e5598c9d6c60136"],"x":425,"y":640,"wires":[["b92dfe56ebec0bf9"]]},{"id":"979e46fdd727e5d2","type":"link out","z":"43b31753070e19b0","name":"Night","mode":"link","links":["2bc4e6effb057af2","2e05a56a4b427a6a","548c688944e2ff36","aec9c78a3fe08029","b37f50802bb36d2b","f8f4b51755c994bf"],"x":360,"y":360,"wires":[]},{"id":"9e9035cf8099234b","type":"link out","z":"43b31753070e19b0","name":"Morning","mode":"link","links":["56b24d0edd0179cd","76b17055d5724e42","c79eac155c9f5885","d220fb70f771e1bb","d8b1d281255232a2","de761f2e526df026"],"x":360,"y":400,"wires":[]},{"id":"d1e83c5e73f88951","type":"link out","z":"43b31753070e19b0","name":"Daylight","mode":"link","links":["3f51c6245a0dd3cb","6061974c84f92423","642dcd9eaa082558","74741eaeb6f44a43","7e6e54dc69b56b7d","c08c40b6d7354435"],"x":360,"y":440,"wires":[]},{"id":"8e5598c9d6c60136","type":"link out","z":"43b31753070e19b0","name":"Evening","mode":"link","links":["2bbd921dad6c2e6d","394249689def1e9c","6b1d3103fddafb33","ac3c673ef5dd46ad","c0b215245a19aaf9","c75046571506c876"],"x":360,"y":480,"wires":[]},{"id":"a7cfb606.aecfc","type":"change","z":"43b31753070e19b0","name":"Ordered array","rules":[{"t":"set","p":"payload","pt":"msg","to":"$keys($$.payload)^($).$lookup($$.payload, $)","tot":"jsonata"},{"t":"set","p":"topic","pt":"msg","to":"rgbw_color","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1160,"y":540,"wires":[["77654077b21096c8"]]},{"id":"ceaa91580b5e254e","type":"change","z":"43b31753070e19b0","name":"Red","rules":[{"t":"set","p":"topic","pt":"msg","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":260,"wires":[["2b1f7419.779bc4","ff16a2542e8d4193"]]},{"id":"73cb286d5b8b58c6","type":"change","z":"43b31753070e19b0","name":"Green","rules":[{"t":"set","p":"topic","pt":"msg","to":"1","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":420,"wires":[["2b1f7419.779bc4","ff16a2542e8d4193"]]},{"id":"5b72ab3f62d72eb8","type":"change","z":"43b31753070e19b0","name":"Blue","rules":[{"t":"set","p":"topic","pt":"msg","to":"2","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":910,"y":580,"wires":[["2b1f7419.779bc4","ff16a2542e8d4193"]]},{"id":"327d15b9e8acc8b8","type":"change","z":"43b31753070e19b0","name":"White","rules":[{"t":"set","p":"topic","pt":"msg","to":"3","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":850,"y":680,"wires":[["798575a0e711f26e"]]},{"id":"07a93e2506a56bf4","type":"spline-curve","z":"43b31753070e19b0","name":"white night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":0.251,"y":0},{"x":0.744,"y":0},{"x":1,"y":0}],"x":570,"y":680,"wires":[["e35665db7818a5bf"]]},{"id":"7e089ec04a10ee1d","type":"spline-curve","z":"43b31753070e19b0","name":"white morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":0.42,"y":0.018},{"x":0.54,"y":0.051},{"x":0.587,"y":0.101},{"x":0.817,"y":0.675},{"x":1,"y":0.85}],"x":560,"y":720,"wires":[["e35665db7818a5bf"]]},{"id":"8a0e55ccb2eb515a","type":"spline-curve","z":"43b31753070e19b0","name":"white day curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.123,"y":0.927},{"x":0.5,"y":1},{"x":0.92,"y":0.904},{"x":1,"y":0.85}],"x":580,"y":760,"wires":[["e35665db7818a5bf"]]},{"id":"b5ec31986b77721e","type":"spline-curve","z":"43b31753070e19b0","name":"white evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.363,"y":0.29},{"x":1,"y":0}],"x":580,"y":800,"wires":[["e35665db7818a5bf"]]},{"id":"d461185209d0d5c5","type":"node-red-contrib-colorspace","z":"43b31753070e19b0","name":"","target":"payload","x":1260,"y":400,"wires":[["4eba4b2103bf1483"]]},{"id":"02edc8b9fbf90580","type":"change","z":"43b31753070e19b0","name":"rgb payload to convert","rules":[{"t":"set","p":"topic","pt":"msg","to":"rgb_color","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\t \"rgb\": {\t \"red\": payload[0].\"0\",\t \"green\": payload[0].\"1\",\t \"blue\": payload[0].\"2\"\t }\t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1280,"y":340,"wires":[["d461185209d0d5c5"]]},{"id":"2b1f7419.779bc4","type":"join","z":"43b31753070e19b0","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1070,"y":480,"wires":[["a7cfb606.aecfc"]]},{"id":"f6609b5cd420ca76","type":"function","z":"43b31753070e19b0","name":"Times of Day","func":"var newmsg = JSON.parse(JSON.stringify(msg));\nnewmsg.payload.times_of_day = {};\n\nconst processTimeOfDay = function(nme, obj, name_start, name_end) {\n var ret = {};\n ret.name = nme;\n ret.start = obj.times[name_start].ts;\n ret.end = obj.times[name_end].ts;\n ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);\n \n \n // to cover range starting before midnight and ending after it.\n if (ret.start > ret.end)\n {\n var a;\n\n // before midnight\n if (ret.start < obj.ts) \n {\n a = new Date(ret.end);\n a.setUTCDate(a.getUTCDate() + 1);\n ret.end = a.getTime();\n \n \n }\n else if (ret.end > obj.ts) \n {\n a = new Date(ret.start);\n a.setUTCDate(a.getUTCDate() - 1);\n ret.start = a.getTime();\n\n }\n\n }\n \n ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);\n \n obj.times_of_day[nme] = ret;\n if (ret.start <= obj.ts && obj.ts < ret.end ) obj.times_of_day.active = ret;\n}\n\nprocessTimeOfDay('night', newmsg.payload, \"blueHourDuskStart\", \"blueHourDawnEnd\");\nprocessTimeOfDay('morning', newmsg.payload, \"blueHourDawnEnd\", \"goldenHourDawnEnd\");\nprocessTimeOfDay('day', newmsg.payload, \"goldenHourDawnEnd\", \"goldenHourDuskStart\");\nprocessTimeOfDay('evening', newmsg.payload, \"goldenHourDuskStart\", \"blueHourDuskStart\");\n\nreturn newmsg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":170,"y":320,"wires":[["f0d97d577f05a92c"]]},{"id":"7b7d05b4b9f34f8b","type":"ha-sensor","z":"43b31753070e19b0","name":"Brightness","entityConfig":"6fe522b12d05f493","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"block","outputProperties":[],"x":850,"y":160,"wires":[[]]},{"id":"4eba4b2103bf1483","type":"ha-sensor","z":"43b31753070e19b0","name":"Kelvin","entityConfig":"2cae8b2454f146ca","version":0,"state":"payload.temperature","stateType":"msg","attributes":[],"inputOverride":"block","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"x":1270,"y":460,"wires":[[]]},{"id":"798575a0e711f26e","type":"ha-sensor","z":"43b31753070e19b0","name":"White","entityConfig":"50c76bf3077ab54f","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"block","outputProperties":[],"x":910,"y":620,"wires":[["2b1f7419.779bc4"]]},{"id":"77654077b21096c8","type":"function","z":"43b31753070e19b0","name":"Array to String","func":"const arr = msg.payload;\nconst myJSON = JSON.stringify(arr);\nmsg.payload = myJSON\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1240,"y":600,"wires":[["e1985b888f2d4735"]]},{"id":"e1985b888f2d4735","type":"ha-sensor","z":"43b31753070e19b0","name":"Aquarium RGBW","entityConfig":"874a3e4cd4ef8db7","version":0,"state":"payload","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"data"}],"x":1290,"y":660,"wires":[[]]},{"id":"ff16a2542e8d4193","type":"join","z":"43b31753070e19b0","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1070,"y":360,"wires":[["02edc8b9fbf90580"]]},{"id":"31826811.22a458","type":"position-config","name":"Home Location","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12"},{"id":"6fe522b12d05f493","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"13be9f2f7ff837e4","name":"Aquarium Brightness","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Aquarium Brightness"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"2cae8b2454f146ca","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"f69a208bb19d2c8d","name":"Aquarium Kelvin","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Aquarium Kelvin"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"50c76bf3077ab54f","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"1212bb856f65626c","name":"Aquarium White","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Aquarium White"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"874a3e4cd4ef8db7","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"4f4083b8e900272d","name":"Aquarium RGBW","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Aquarium RGBW"},{"property":"icon","value":"mdi:palette"},{"property":"entity_category","value":"config"},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"c879ac61.99cd1","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"13be9f2f7ff837e4","type":"ha-device-config","name":"Aquarium Brightness","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"f69a208bb19d2c8d","type":"ha-device-config","name":"Aquarium Kelvin","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"1212bb856f65626c","type":"ha-device-config","name":"Aquarium White","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"4f4083b8e900272d","type":"ha-device-config","name":"Aquarium RGBW","hwVersion":"","manufacturer":"Node-RED","model":"H801 WiFi","swVersion":"ESPHome"}]
I am also using global variables but I also export those to sensors in HA and I use those sensors in templates in automations…
[{"id":"e812678d.651e28","type":"subflow","name":"Circadian Calculator","info":"","category":"time and astro","in":[{"x":80,"y":80,"wires":[{"id":"aa4b86d8.b17118"}]}],"out":[{"x":890,"y":100,"wires":[{"id":"40de744.1e2ca8c","port":0}]},{"x":890,"y":160,"wires":[{"id":"15b473ec45fa7fc4","port":0}]},{"x":930,"y":260,"wires":[{"id":"6f365d7d05905955","port":0}]},{"x":930,"y":320,"wires":[{"id":"c26bdcca.eb483","port":0}]}],"env":[],"meta":{},"color":"#FFCC66","inputLabels":["Trigger"],"outputLabels":["Brightness Value","Brightness Percent","Mireds","Kelvin"]},{"id":"5de89261.4fb97c","type":"switch","z":"e812678d.651e28","name":"curve switch","property":"payload.times_of_day.active.name","propertyType":"msg","rules":[{"t":"eq","v":"night","vt":"str"},{"t":"eq","v":"morning","vt":"str"},{"t":"eq","v":"day","vt":"str"},{"t":"eq","v":"evening","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":250,"y":220,"wires":[["ba17c1e6.e6f58","840431b7.eeefc"],["e5bb5a04.a33948","d4d99259.d0d7e"],["7c0f0774.90adf8","6ac1af7.dddb15"],["23b260f9.19f78","a907f5f4.0bf488"]]},{"id":"ba17c1e6.e6f58","type":"spline-curve","z":"e812678d.651e28","name":"night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.3},{"x":0.333,"y":0.037},{"x":0.477,"y":0},{"x":0.783,"y":0},{"x":1,"y":0}],"x":490,"y":80,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"e5bb5a04.a33948","type":"spline-curve","z":"e812678d.651e28","name":"morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.01},{"x":0.132,"y":0.01},{"x":0.269,"y":0.027},{"x":0.449,"y":0.124},{"x":0.676,"y":0.334},{"x":1,"y":0.75}],"x":500,"y":120,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"23b260f9.19f78","type":"spline-curve","z":"e812678d.651e28","name":"evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.036,"y":0.78},{"x":0.176,"y":0.63},{"x":1,"y":0.3}],"x":500,"y":200,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"7c0f0774.90adf8","type":"spline-curve","z":"e812678d.651e28","name":"daylight curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.744},{"x":0.03,"y":0.838},{"x":0.097,"y":0.941},{"x":0.183,"y":1},{"x":0.86,"y":0.995},{"x":0.943,"y":0.931},{"x":1,"y":0.85}],"x":500,"y":160,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"840431b7.eeefc","type":"spline-curve","z":"e812678d.651e28","name":"night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.5},{"x":0.067,"y":0.368},{"x":0.133,"y":0.265},{"x":0.27,"y":0.171},{"x":0.333,"y":0.16},{"x":0.506,"y":0.124},{"x":0.606,"y":0}],"x":490,"y":240,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"d4d99259.d0d7e","type":"spline-curve","z":"e812678d.651e28","name":"morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":0.42,"y":0.018},{"x":0.54,"y":0.051},{"x":0.587,"y":0.101},{"x":0.817,"y":0.675},{"x":1,"y":0.85}],"x":500,"y":280,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"a907f5f4.0bf488","type":"spline-curve","z":"e812678d.651e28","name":"evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.787,"y":0.598},{"x":1,"y":0.5}],"x":500,"y":360,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"6ac1af7.dddb15","type":"spline-curve","z":"e812678d.651e28","name":"daylight curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.123,"y":0.927},{"x":0.5,"y":1},{"x":0.92,"y":0.904},{"x":1,"y":0.85}],"x":500,"y":320,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"40de744.1e2ca8c","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"254","action":"clamp","round":true,"property":"payload","name":"","x":710,"y":100,"wires":[[]]},{"id":"c26bdcca.eb483","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"2700","maxout":"6500","action":"clamp","round":true,"property":"payload","name":"","x":730,"y":320,"wires":[[]]},{"id":"aa4b86d8.b17118","type":"sun-position","z":"e812678d.651e28","name":"","positionConfig":"31826811.22a458","rules":[],"onlyOnChange":"true","topic":"","outputs":1,"start":"","startType":"none","startOffset":0,"startOffsetType":"num","startOffsetMultiplier":60000,"end":"","endType":"none","endOffset":0,"endOffsetType":"num","endOffsetMultiplier":60000,"x":210,"y":80,"wires":[["717191f7a71b0df4"]]},{"id":"15b473ec45fa7fc4","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"100","action":"clamp","round":true,"property":"payload","name":"","x":710,"y":160,"wires":[[]]},{"id":"6f365d7d05905955","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"370","maxout":"154","action":"clamp","round":true,"property":"payload","name":"","x":720,"y":260,"wires":[[]]},{"id":"717191f7a71b0df4","type":"function","z":"e812678d.651e28","name":"Times of Day","func":"var newmsg = JSON.parse(JSON.stringify(msg));\nnewmsg.payload.times_of_day = {};\n\nconst processTimeOfDay = function(nme, obj, name_start, name_end) {\n var ret = {};\n ret.name = nme;\n ret.start = obj.times[name_start].ts;\n ret.end = obj.times[name_end].ts;\n ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);\n \n \n // to cover range starting before midnight and ending after it.\n if (ret.start > ret.end)\n {\n var a;\n\n // before midnight\n if (ret.start < obj.ts) \n {\n a = new Date(ret.end);\n a.setUTCDate(a.getUTCDate() + 1);\n ret.end = a.getTime();\n \n \n }\n else if (ret.end > obj.ts) \n {\n a = new Date(ret.start);\n a.setUTCDate(a.getUTCDate() - 1);\n ret.start = a.getTime();\n\n }\n\n }\n \n ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);\n \n obj.times_of_day[nme] = ret;\n if (ret.start <= obj.ts && obj.ts < ret.end ) obj.times_of_day.active = ret;\n}\n\n\nprocessTimeOfDay('night', newmsg.payload, \"astronomicalDusk\", \"astronomicalDawn\");\nprocessTimeOfDay('morning', newmsg.payload, \"astronomicalDawn\", \"goldenHourDawnEnd\");\nprocessTimeOfDay('day', newmsg.payload, \"goldenHourDawnEnd\", \"sunsetStart\");\nprocessTimeOfDay('evening', newmsg.payload, \"sunsetStart\", \"astronomicalDusk\");\n\n\nreturn newmsg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":140,"wires":[["5de89261.4fb97c"]]},{"id":"31826811.22a458","type":"position-config","name":"Home Location","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12"},{"id":"365094a5.72bb5c","type":"subflow:e812678d.651e28","z":"7ea0620.a243ca","name":"","env":[],"x":480,"y":130,"wires":[["5f4a2fbe.d6b89"],["2bd57efd76cfcedf"],["eb1275669172038f","30bf6ebc.f4da52","e54896f13be9148d"],[]]},{"id":"a7bca137.c0d2f","type":"comment","z":"7ea0620.a243ca","name":"Update","info":"","x":90,"y":40,"wires":[]},{"id":"5f4a2fbe.d6b89","type":"function","z":"7ea0620.a243ca","name":"global brightness","func":"var new_brightness = (msg.payload == 254) ? 255 : msg.payload;\nif (new_brightness != global.get('nr_circadian_brightness')){\n global.set('nr_circadian_brightness',new_brightness);\n// return { payload: new_brightness }\n}\nreturn { payload: new_brightness }\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":40,"wires":[["2a30dc124d3af143"]]},{"id":"30bf6ebc.f4da52","type":"function","z":"7ea0620.a243ca","name":"global kelvin","func":"var new_kelvin = Math.round(1000000/msg.payload)\nif (new_kelvin != global.get('nr_circadian_kelvin')) {\n global.set('nr_circadian_kelvin',new_kelvin);\n return {payload: new_kelvin}\n }\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":220,"wires":[["3c129db64c31287f"]]},{"id":"934e0600896a7adb","type":"link out","z":"7ea0620.a243ca","name":"Mireds","mode":"link","links":["43c2e1ab9d4c3a33","46442d133be6f963","9d3d2931ff09f30e","a52970d03d1f30a5","a897dbf21ffb2b4c"],"x":1195,"y":160,"wires":[]},{"id":"b1ee887a5f59e581","type":"link out","z":"7ea0620.a243ca","name":"Brightness","mode":"link","links":["e376d76995dda48c","4c8de271d9d32579","df433767e85260dc","3055458e27486427","4ccd12c7e9fa28f9","d72d56acc2f72b41","b1137e5488a33dda","ffa6896cb76348d5","19af89da0660a8f1","5c549b4f7506d662"],"x":1195,"y":40,"wires":[]},{"id":"eb1275669172038f","type":"function","z":"7ea0620.a243ca","name":"global mireds","func":"var new_mireds = msg.payload\nif (new_mireds != global.get('nr_circadian_mireds')) {\n global.set('nr_circadian_mireds',new_mireds);\n return {payload: new_mireds}\n }\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":160,"wires":[["720badcc22d0246e"]]},{"id":"2bd57efd76cfcedf","type":"function","z":"7ea0620.a243ca","name":"global brightness %","func":"var new_brightness_pct = msg.payload;\nif (new_brightness_pct != global.get('nr_circadian_brightness_pct')) {\n global.set('nr_circadian_brightness_pct',new_brightness_pct);\n return {payload: new_brightness_pct}\n }","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":100,"wires":[["e2ac2146b3a99484"]]},{"id":"53a933a438c1326b","type":"change","z":"7ea0620.a243ca","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"color_temp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1070,"y":160,"wires":[["934e0600896a7adb"]]},{"id":"ba7018086eca537b","type":"change","z":"7ea0620.a243ca","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1070,"y":40,"wires":[["b1ee887a5f59e581"]]},{"id":"f6a0b62593cc81c1","type":"interval-multiples-timer","z":"7ea0620.a243ca","interval":"60000","payload":"","topic":"","name":"Every minute","x":86,"y":120,"wires":[["f7382c3f63fec06f"]],"outputLabels":["timestamp"]},{"id":"b49e0a964008e7ba","type":"inject","z":"7ea0620.a243ca","name":"At startup","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":"5","topic":"","payload":"","payloadType":"date","x":96,"y":160,"wires":[["f7382c3f63fec06f"]]},{"id":"f7382c3f63fec06f","type":"api-current-state","z":"7ea0620.a243ca","name":"Circadian On?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.circadian_lighting","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"date"}],"for":0,"forType":"num","forUnits":"minutes","x":280,"y":136,"wires":[["365094a5.72bb5c"],[]]},{"id":"3c129db64c31287f","type":"ha-sensor","z":"7ea0620.a243ca","name":"Kelvin","entityConfig":"f5e1d08b.a8cd58","version":0,"state":"nr_circadian_kelvin","stateType":"global","attributes":[],"inputOverride":"allow","outputProperties":[],"x":890,"y":220,"wires":[[]]},{"id":"720badcc22d0246e","type":"ha-sensor","z":"7ea0620.a243ca","name":"color_temp","entityConfig":"e80bd956.f2e098","version":0,"state":"nr_circadian_mireds","stateType":"global","attributes":[],"inputOverride":"allow","outputProperties":[],"x":910,"y":160,"wires":[["53a933a438c1326b"]]},{"id":"2a30dc124d3af143","type":"ha-sensor","z":"7ea0620.a243ca","name":"brightness","entityConfig":"476cda43.0f4c94","version":0,"state":"nr_circadian_brightness","stateType":"global","attributes":[],"inputOverride":"block","outputProperties":[],"x":910,"y":40,"wires":[["ba7018086eca537b"]]},{"id":"e2ac2146b3a99484","type":"ha-sensor","z":"7ea0620.a243ca","name":"brightness_pct","entityConfig":"5cd0d7153aaad741","version":0,"state":"nr_circadian_brightness_pct","stateType":"global","attributes":[],"inputOverride":"block","outputProperties":[],"x":920,"y":100,"wires":[[]]},{"id":"e54896f13be9148d","type":"function","z":"7ea0620.a243ca","name":"Kelvin to RGB","func":"var tmpKelvin = Math.round(1000000 / msg.payload)\n\nif (tmpKelvin < 1000) {tmpKelvin = 1000}\nif (tmpKelvin > 40000) {tmpKelvin = 40000}\ntmpKelvin = tmpKelvin / 100\n\n// First: red\nif (tmpKelvin <= 66)\n { r = 255 }\nelse\n{\n // Note: the R-squared value for this approximation is .988\n var tmpCalc = tmpKelvin - 60\n tmpCalc = 329.698727446 * (tmpCalc ^ -0.1332047592)\n var r = Math.round(tmpCalc)\n if (r < 0) {r = 0}\n if (r > 255) {r = 255}\n}\n\n// Second: green\nif (tmpKelvin <= 66) \n{\n // Note: the R-squared value for this approximation is .996\n tmpCalc = tmpKelvin\n tmpCalc = 99.4708025861 * Math.log(tmpCalc) - 161.1195681661\n var g = Math.round(tmpCalc)\n if (g < 0) {g = 0}\n if (g > 255) {g = 255}\n} else\n{\n // Note: the R-squared value for this approximation is .987\n tmpCalc = tmpKelvin - 60\n tmpCalc = 288.1221695283 * (tmpCalc ^ -0.0755148492)\n g = Math.round(tmpCalc)\n if (g < 0) { g = 0 }\n if (g > 255) { g = 255 }\n}\n\n// Third: blue\nif (tmpKelvin >= 66)\n { var b = 255 }\nelse if (tmpKelvin <= 19)\n { b = 0 }\nelse \n {\n // Note: the R-squared value for this approximation is .998\n tmpCalc = tmpKelvin - 10\n tmpCalc = 138.5177312231 * Math.log(tmpCalc) - 305.0447927307\n }\nb = Math.round(tmpCalc)\nif (b < 0) { b = 0 }\nif (b > 255) { b = 255 }\n\nif ([r,g,b] != global.get('nr_circadian_rgb')) {\n global.set('nr_circadian_rgb', [r,g,b]);\n return { payload: [r, g, b] }\n }\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":280,"wires":[["412288630f9120b7"]]},{"id":"be1c8e1a66aec806","type":"change","z":"7ea0620.a243ca","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"rgb_color","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1070,"y":280,"wires":[["eb72c612dcb6c962"]]},{"id":"eb72c612dcb6c962","type":"link out","z":"7ea0620.a243ca","name":"RGB","mode":"link","links":["c1cff865a0ee9d10"],"x":1195,"y":280,"wires":[]},{"id":"412288630f9120b7","type":"ha-sensor","z":"7ea0620.a243ca","name":"RGB","entityConfig":"10179c1c0d06ea3c","version":0,"state":" ","stateType":"str","attributes":[{"property":"rgb_color","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":890,"y":280,"wires":[["be1c8e1a66aec806"]]},{"id":"c879ac61.99cd1","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"f5e1d08b.a8cd58","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"7e438167417be2db","name":"Circadian kelvin","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Circadian Kelvin"},{"property":"icon","value":"mdi:brightness-6"},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"K"},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false},{"id":"e80bd956.f2e098","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"f5ff2695a5677b41","name":"Circadian color_temp","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Circadian color_temp"},{"property":"icon","value":"mdi:brightness-6"},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false},{"id":"476cda43.0f4c94","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"d03039723c3f87fe","name":"Circadian brightness","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Circadian Brightness"},{"property":"icon","value":"mdi:brightness-auto"},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false},{"id":"5cd0d7153aaad741","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"c260472dc44e142d","name":"Circadian brightness_pct","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Circadian Brightness %"},{"property":"icon","value":"mdi:brightness-percent"},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false},{"id":"10179c1c0d06ea3c","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"3619f11c08848aa5","name":"Circadian RGB","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Circadian RGB"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false},{"id":"7e438167417be2db","type":"ha-device-config","name":"nr_circadian_kelvin","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"f5ff2695a5677b41","type":"ha-device-config","name":"nr_circadian_color_temp","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"d03039723c3f87fe","type":"ha-device-config","name":"nr_circadian_brightness","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"c260472dc44e142d","type":"ha-device-config","name":"nr_circadian_brightness_pct","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"3619f11c08848aa5","type":"ha-device-config","name":"nr_circadian_rgb","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""}]
alias: Automatic Lighting - Office
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.my_pc_is_active
id: PC Active
to: "on"
- platform: state
entity_id:
- binary_sensor.office_occupancy
id: Motion on
to: "on"
- platform: state
entity_id:
- binary_sensor.my_pc_is_active
id: PC Idle
to: "off"
for:
hours: 0
minutes: 0
seconds: 0
- platform: state
entity_id:
- binary_sensor.office_occupancy
to: "off"
id: Motion off
for:
seconds: "{{ states('input_number.office_lights_auto_off_time') }}"
condition: []
action:
- choose:
- conditions:
- condition: or
conditions:
- condition: trigger
id: PC Active
- condition: trigger
id: Motion on
sequence:
- if:
- condition: not
conditions:
- condition: state
entity_id: sensor.windows_11_monitorpowerstate
state: PowerOn
then:
- service: light.turn_on
data: {}
target:
entity_id: light.pc_monitor
- if:
- condition: state
entity_id: light.office_lights
state: "off"
then:
- service: light.turn_on
data:
brightness: "{{ states('sensor.circadian_brightness') }}"
color_temp: "{{ states('sensor.circadian_color_temp') }}"
target:
entity_id: light.office_lights
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.my_pc_is_active
state: "off"
- condition: state
entity_id: binary_sensor.office_occupancy
state: "off"
sequence:
- service: light.turn_off
data: {}
target:
area_id: office
default: []
mode: restart
First of all, thank you very much for this!! I’m having some issues with the “Who” subflow, specially the “auth” read file node, not sure what I should be setting mine to, I run HA on Unraid, docker.
I was about to comment that as long as you can provide read access to the auth file from HA to nodered you should be fine.
However it may not be wise security wise.
As the document is only used as a lookup table, if your users don’t change you may simply copy/paste the user blob in the function and remove the preceeeding nodes…
Sorry I’m not sure I understand. Copy the user blob to where? And then I’m assuming you mean delete the move, auth and json nodes?
Hi, I really like your work, but it took me some time to set everything up (first time node red user).
I don’t see a point having different devices for each entity, as opposed to one device, so I made some changes I’d like to share, but just a question before it. When I export from node red, under Global Configuration Nodes
it shows Home location
and Home Assistant
. I guess they have some personal information, that I don’t want to share. How can I remove them from the export?
Hello, @dbrunt,
I’m trying to use your implementation. Would you mind sharing your entire flow? I’m having a bit of trouble stitching everything together that you shared.
Here is my Circadian flow (part 1)
[{"id":"e812678d.651e28","type":"subflow","name":"Circadian Calculator","info":"","category":"time and astro","in":[{"x":80,"y":80,"wires":[{"id":"aa4b86d8.b17118"}]}],"out":[{"x":890,"y":100,"wires":[{"id":"40de744.1e2ca8c","port":0}]},{"x":890,"y":160,"wires":[{"id":"15b473ec45fa7fc4","port":0}]},{"x":930,"y":260,"wires":[{"id":"6f365d7d05905955","port":0}]},{"x":930,"y":320,"wires":[{"id":"c26bdcca.eb483","port":0}]}],"env":[],"meta":{},"color":"#FFCC66","inputLabels":["Trigger"],"outputLabels":["Brightness Value","Brightness Percent","Mireds","Kelvin"]},{"id":"5de89261.4fb97c","type":"switch","z":"e812678d.651e28","name":"curve switch","property":"payload.times_of_day.active.name","propertyType":"msg","rules":[{"t":"eq","v":"night","vt":"str"},{"t":"eq","v":"morning","vt":"str"},{"t":"eq","v":"day","vt":"str"},{"t":"eq","v":"evening","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":250,"y":220,"wires":[["ba17c1e6.e6f58","840431b7.eeefc"],["e5bb5a04.a33948","d4d99259.d0d7e"],["7c0f0774.90adf8","6ac1af7.dddb15"],["23b260f9.19f78","a907f5f4.0bf488"]]},{"id":"ba17c1e6.e6f58","type":"spline-curve","z":"e812678d.651e28","name":"night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.3},{"x":0.333,"y":0.037},{"x":0.477,"y":0},{"x":0.783,"y":0},{"x":1,"y":0}],"x":490,"y":80,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"e5bb5a04.a33948","type":"spline-curve","z":"e812678d.651e28","name":"morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.01},{"x":0.132,"y":0.01},{"x":0.269,"y":0.027},{"x":0.449,"y":0.124},{"x":0.676,"y":0.334},{"x":1,"y":0.75}],"x":500,"y":120,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"23b260f9.19f78","type":"spline-curve","z":"e812678d.651e28","name":"evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.036,"y":0.78},{"x":0.176,"y":0.63},{"x":1,"y":0.3}],"x":500,"y":200,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"7c0f0774.90adf8","type":"spline-curve","z":"e812678d.651e28","name":"daylight curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.744},{"x":0.03,"y":0.838},{"x":0.097,"y":0.941},{"x":0.183,"y":1},{"x":0.86,"y":0.995},{"x":0.943,"y":0.931},{"x":1,"y":0.85}],"x":500,"y":160,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"840431b7.eeefc","type":"spline-curve","z":"e812678d.651e28","name":"night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.5},{"x":0.067,"y":0.368},{"x":0.133,"y":0.265},{"x":0.27,"y":0.171},{"x":0.333,"y":0.16},{"x":0.506,"y":0.124},{"x":0.606,"y":0}],"x":490,"y":240,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"d4d99259.d0d7e","type":"spline-curve","z":"e812678d.651e28","name":"morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":0.42,"y":0.018},{"x":0.54,"y":0.051},{"x":0.587,"y":0.101},{"x":0.817,"y":0.675},{"x":1,"y":0.85}],"x":500,"y":280,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"a907f5f4.0bf488","type":"spline-curve","z":"e812678d.651e28","name":"evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.787,"y":0.598},{"x":1,"y":0.5}],"x":500,"y":360,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"6ac1af7.dddb15","type":"spline-curve","z":"e812678d.651e28","name":"daylight curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.123,"y":0.927},{"x":0.5,"y":1},{"x":0.92,"y":0.904},{"x":1,"y":0.85}],"x":500,"y":320,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"40de744.1e2ca8c","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"254","action":"clamp","round":true,"property":"payload","name":"","x":710,"y":100,"wires":[[]]},{"id":"c26bdcca.eb483","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"2000","maxout":"3500","action":"clamp","round":true,"property":"payload","name":"","x":730,"y":320,"wires":[[]]},{"id":"aa4b86d8.b17118","type":"sun-position","z":"e812678d.651e28","name":"","positionConfig":"31826811.22a458","rules":[],"onlyOnChange":"true","topic":"","outputs":1,"start":"","startType":"none","startOffset":0,"startOffsetType":"num","startOffsetMultiplier":60000,"end":"","endType":"none","endOffset":0,"endOffsetType":"num","endOffsetMultiplier":60000,"x":210,"y":80,"wires":[["717191f7a71b0df4"]]},{"id":"15b473ec45fa7fc4","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"100","action":"clamp","round":true,"property":"payload","name":"","x":710,"y":160,"wires":[[]]},{"id":"6f365d7d05905955","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"370","maxout":"154","action":"clamp","round":true,"property":"payload","name":"","x":720,"y":260,"wires":[[]]},{"id":"717191f7a71b0df4","type":"function","z":"e812678d.651e28","name":"Times of Day","func":"var newmsg = JSON.parse(JSON.stringify(msg));\nnewmsg.payload.times_of_day = {};\n\nconst processTimeOfDay = function(nme, obj, name_start, name_end) {\n var ret = {};\n ret.name = nme;\n ret.start = obj.times[name_start].ts;\n ret.end = obj.times[name_end].ts;\n ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);\n \n \n // to cover range starting before midnight and ending after it.\n if (ret.start > ret.end)\n {\n var a;\n\n // before midnight\n if (ret.start < obj.ts) \n {\n a = new Date(ret.end);\n a.setUTCDate(a.getUTCDate() + 1);\n ret.end = a.getTime();\n \n \n }\n else if (ret.end > obj.ts) \n {\n a = new Date(ret.start);\n a.setUTCDate(a.getUTCDate() - 1);\n ret.start = a.getTime();\n\n }\n\n }\n \n ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);\n \n obj.times_of_day[nme] = ret;\n if (ret.start <= obj.ts && obj.ts < ret.end ) obj.times_of_day.active = ret;\n}\n\n\nprocessTimeOfDay('night', newmsg.payload, \"astronomicalDusk\", \"astronomicalDawn\");\nprocessTimeOfDay('morning', newmsg.payload, \"astronomicalDawn\", \"goldenHourDawnEnd\");\nprocessTimeOfDay('day', newmsg.payload, \"goldenHourDawnEnd\", \"sunsetStart\");\nprocessTimeOfDay('evening', newmsg.payload, \"sunsetStart\", \"astronomicalDusk\");\n\n\nreturn newmsg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":140,"wires":[["5de89261.4fb97c"]]},{"id":"31826811.22a458","type":"position-config","name":"Home Location","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12"},{"id":"365094a5.72bb5c","type":"subflow:e812678d.651e28","z":"7ea0620.a243ca","name":"","env":[],"x":480,"y":130,"wires":[["5f4a2fbe.d6b89"],["2bd57efd76cfcedf"],["eb1275669172038f"],["e54896f13be9148d","30bf6ebc.f4da52"]]},{"id":"a7bca137.c0d2f","type":"comment","z":"7ea0620.a243ca","name":"Update","info":"","x":90,"y":40,"wires":[]},{"id":"5f4a2fbe.d6b89","type":"function","z":"7ea0620.a243ca","name":"global brightness","func":"var new_brightness = (msg.payload == 254) ? 255 : msg.payload;\nnode.status({ fill: \"yellow\", shape: \"dot\", text: new_brightness });\nif (new_brightness != global.get('nr_circadian_brightness')){\n global.set('nr_circadian_brightness',new_brightness);\n return { payload: new_brightness }\n}\nreturn { payload: new_brightness }\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":40,"wires":[["2a30dc124d3af143"]]},{"id":"30bf6ebc.f4da52","type":"function","z":"7ea0620.a243ca","name":"global kelvin","func":"/* var new_kelvin = Math.round(1000000 / msg.payload) */\nvar new_kelvin = msg.payload\nnode.status({ fill: \"yellow\", shape: \"dot\", text: new_kelvin });\nif (new_kelvin != global.get('nr_circadian_kelvin')) {\n global.set('nr_circadian_kelvin',new_kelvin);\n return {payload: new_kelvin}\n }\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":220,"wires":[["3c129db64c31287f"]]},{"id":"934e0600896a7adb","type":"link out","z":"7ea0620.a243ca","name":"Mireds","mode":"link","links":["43c2e1ab9d4c3a33","46442d133be6f963","9d3d2931ff09f30e","a52970d03d1f30a5","a897dbf21ffb2b4c"],"x":1195,"y":160,"wires":[]},{"id":"b1ee887a5f59e581","type":"link out","z":"7ea0620.a243ca","name":"Brightness","mode":"link","links":["e376d76995dda48c","4c8de271d9d32579","df433767e85260dc","3055458e27486427","4ccd12c7e9fa28f9","d72d56acc2f72b41","b1137e5488a33dda","ffa6896cb76348d5","19af89da0660a8f1","5c549b4f7506d662"],"x":1195,"y":40,"wires":[]},{"id":"eb1275669172038f","type":"function","z":"7ea0620.a243ca","name":"global mireds","func":"var new_mireds = msg.payload\nnode.status({ fill: \"yellow\", shape: \"dot\", text: new_mireds });\nif (new_mireds != global.get('nr_circadian_mireds')) {\n global.set('nr_circadian_mireds',new_mireds);\n return {payload: new_mireds}\n }\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":160,"wires":[["720badcc22d0246e"]]},{"id":"2bd57efd76cfcedf","type":"function","z":"7ea0620.a243ca","name":"global brightness %","func":"var new_brightness_pct = msg.payload;\nnode.status({ fill: \"yellow\", shape: \"dot\", text: new_brightness_pct }); \nif (new_brightness_pct != global.get('nr_circadian_brightness_pct')) {\n global.set('nr_circadian_brightness_pct',new_brightness_pct);\n }\n// global.set('nr_circadian_brightness_pct', new_brightness_pct);\nreturn { payload: new_brightness_pct }","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":100,"wires":[["e2ac2146b3a99484"]]},{"id":"53a933a438c1326b","type":"change","z":"7ea0620.a243ca","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"color_temp","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1070,"y":160,"wires":[["934e0600896a7adb"]]},{"id":"ba7018086eca537b","type":"change","z":"7ea0620.a243ca","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"brightness","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1070,"y":40,"wires":[["b1ee887a5f59e581"]]},{"id":"b49e0a964008e7ba","type":"inject","z":"7ea0620.a243ca","name":"inject","props":[{"p":"payload"}],"repeat":"60","crontab":"","once":true,"onceDelay":"10","topic":"","payload":"","payloadType":"date","x":130,"y":136,"wires":[["f7382c3f63fec06f"]]},{"id":"f7382c3f63fec06f","type":"api-current-state","z":"7ea0620.a243ca","name":"Circadian On?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.circadian_lighting","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"date"}],"for":0,"forType":"num","forUnits":"minutes","x":280,"y":136,"wires":[["365094a5.72bb5c"],[]]},{"id":"3c129db64c31287f","type":"ha-sensor","z":"7ea0620.a243ca","name":"Kelvin","entityConfig":"f5e1d08b.a8cd58","version":0,"state":"nr_circadian_kelvin","stateType":"global","attributes":[],"inputOverride":"allow","outputProperties":[],"x":890,"y":220,"wires":[[]]},{"id":"720badcc22d0246e","type":"ha-sensor","z":"7ea0620.a243ca","name":"color_temp","entityConfig":"e80bd956.f2e098","version":0,"state":"nr_circadian_mireds","stateType":"global","attributes":[],"inputOverride":"allow","outputProperties":[],"x":910,"y":160,"wires":[["53a933a438c1326b"]]},{"id":"2a30dc124d3af143","type":"ha-sensor","z":"7ea0620.a243ca","name":"brightness","entityConfig":"89a63eeab2eda127","version":0,"state":"nr_circadian_brightness","stateType":"global","attributes":[],"inputOverride":"block","outputProperties":[],"x":910,"y":40,"wires":[["ba7018086eca537b"]]},{"id":"e2ac2146b3a99484","type":"ha-sensor","z":"7ea0620.a243ca","name":"brightness_pct","entityConfig":"5cd0d7153aaad741","version":0,"state":"nr_circadian_brightness_pct","stateType":"global","attributes":[],"inputOverride":"block","outputProperties":[],"x":920,"y":100,"wires":[[]]},{"id":"e54896f13be9148d","type":"function","z":"7ea0620.a243ca","name":"Kelvin to RGB","func":"/* var tmpKelvin = Math.round(1000000 / msg.payload) */\nvar tmpKelvin = msg.payload\n\nif (tmpKelvin < 1000) {tmpKelvin = 1000}\nif (tmpKelvin > 40000) {tmpKelvin = 40000}\ntmpKelvin = tmpKelvin / 100\n\n// First: red\nif (tmpKelvin <= 66)\n { r = 255 }\nelse\n{\n // Note: the R-squared value for this approximation is .988\n var tmpCalc = tmpKelvin - 60\n tmpCalc = 329.698727446 * (tmpCalc ^ -0.1332047592)\n var r = Math.round(tmpCalc)\n if (r < 0) {r = 0}\n if (r > 255) {r = 255}\n}\n\n// Second: green\nif (tmpKelvin <= 66) \n{\n // Note: the R-squared value for this approximation is .996\n tmpCalc = tmpKelvin\n tmpCalc = 99.4708025861 * Math.log(tmpCalc) - 161.1195681661\n var g = Math.round(tmpCalc)\n if (g < 0) {g = 0}\n if (g > 255) {g = 255}\n} else\n{\n // Note: the R-squared value for this approximation is .987\n tmpCalc = tmpKelvin - 60\n tmpCalc = 288.1221695283 * (tmpCalc ^ -0.0755148492)\n g = Math.round(tmpCalc)\n if (g < 0) { g = 0 }\n if (g > 255) { g = 255 }\n}\n\n// Third: blue\nif (tmpKelvin >= 66)\n { var b = 255 }\nelse if (tmpKelvin <= 19)\n { b = 0 }\nelse \n {\n // Note: the R-squared value for this approximation is .998\n tmpCalc = tmpKelvin - 10\n tmpCalc = 138.5177312231 * Math.log(tmpCalc) - 305.0447927307\n }\nb = Math.round(tmpCalc)\nif (b < 0) { b = 0 }\nif (b > 255) { b = 255 }\nnode.status({ fill: \"yellow\", shape: \"dot\", text: [r,g,b].toString() });\nif ([r,g,b] != global.get('nr_circadian_rgb')) {\n global.set('nr_circadian_rgb', [r,g,b]);\n return { payload: [r, g, b] }\n }\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":720,"y":280,"wires":[["412288630f9120b7"]]},{"id":"be1c8e1a66aec806","type":"change","z":"7ea0620.a243ca","name":"","rules":[{"t":"set","p":"topic","pt":"msg","to":"rgb_color","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1070,"y":280,"wires":[["eb72c612dcb6c962"]]},{"id":"eb72c612dcb6c962","type":"link out","z":"7ea0620.a243ca","name":"RGB","mode":"link","links":["c1cff865a0ee9d10"],"x":1195,"y":280,"wires":[]},{"id":"412288630f9120b7","type":"ha-sensor","z":"7ea0620.a243ca","name":"RGB","entityConfig":"10179c1c0d06ea3c","version":0,"state":"$string(msg.payload)\t","stateType":"jsonata","attributes":[{"property":"rgb_color","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":890,"y":280,"wires":[["be1c8e1a66aec806"]]},{"id":"d540390ded8a1102","type":"debug","z":"7ea0620.a243ca","name":"debug 11","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":440,"y":40,"wires":[]},{"id":"c879ac61.99cd1","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"f5e1d08b.a8cd58","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"7e438167417be2db","name":"Circadian kelvin","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Circadian Kelvin"},{"property":"icon","value":"mdi:brightness-6"},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"K"},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false},{"id":"e80bd956.f2e098","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"f5ff2695a5677b41","name":"Circadian color_temp","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Circadian color_temp"},{"property":"icon","value":"mdi:brightness-6"},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false},{"id":"89a63eeab2eda127","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"8a6ed9d1ec9d78a6","name":"Circadian brightness","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":""},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"5cd0d7153aaad741","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"c260472dc44e142d","name":"Circadian brightness_pct","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Circadian Brightness %"},{"property":"icon","value":"mdi:brightness-percent"},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false},{"id":"10179c1c0d06ea3c","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"3619f11c08848aa5","name":"Circadian RGB","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Circadian RGB"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":true,"debugEnabled":false},{"id":"7e438167417be2db","type":"ha-device-config","name":"nr_circadian_kelvin","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"f5ff2695a5677b41","type":"ha-device-config","name":"nr_circadian_color_temp","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"8a6ed9d1ec9d78a6","type":"ha-device-config","name":"Circadian brightness","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"c260472dc44e142d","type":"ha-device-config","name":"nr_circadian_brightness_pct","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"3619f11c08848aa5","type":"ha-device-config","name":"nr_circadian_rgb","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""}]
(part 2)
[{"id":"03454e69d1fb38da","type":"subflow","name":"Color / Brightness","info":"Color / Brightness Control commands for q-gate node","category":"","in":[{"x":340,"y":140,"wires":[{"id":"e9076938078efe18"}]}],"out":[{"x":640,"y":60,"wires":[{"id":"e9076938078efe18","port":0}]},{"x":640,"y":120,"wires":[{"id":"e9076938078efe18","port":1}]},{"x":640,"y":180,"wires":[{"id":"e9076938078efe18","port":2}]}],"env":[],"meta":{},"color":"#DDAA99","status":{"x":640,"y":240,"wires":[]}},{"id":"e9076938078efe18","type":"function","z":"03454e69d1fb38da","name":"","func":"var entity_id = msg.data.entity_id\nvar current_brightness = msg.data.new_state.attributes.brightness;\nvar current_color_temp = msg.data.new_state.attributes.color_temp;\nvar circadian_mireds = global.get(\"nr_circadian_mireds\");\nvar circadian_brightness = global.get(\"nr_circadian_brightness\");\n/*\nvar calculated_brightness_state = Math.round(circadian_brightness * 0.996078431);\nif (calculated_brightness_state == 254) {calculated_brightness_state = 255}\n*/\ncircadian_brightness = Math.round(circadian_brightness * 0.996078431) + Math.floor(circadian_brightness/255);\n\nvar debug = \n {\n \"Entity\": entity_id,\n \"Old color\": msg.data.old_state.attributes.color_temp,\n \"New color\": msg.data.new_state.attributes.color_temp,\n \"Current color_temp\": current_color_temp,\n \"Circadian mireds\": circadian_mireds,\n \"Old brightness\": msg.data.old_state.attributes.brightness,\n \"New brightness\": msg.data.new_state.attributes.brightness,\n \"Current brightness\": current_brightness,\n \"Circadian brightness\": circadian_brightness\n }\n\nif (msg.data.old_state.state == \"on\" && msg.data.new_state.state == \"on\"){\n\n if (current_color_temp == circadian_mireds &&\n current_brightness == circadian_brightness){\n return [{topic: \"control\", payload: \"open\"}, {topic: \"control\", payload: \"open\"}, debug]\n }\n if (current_color_temp != circadian_mireds &&\n current_brightness == circadian_brightness){\n return [{topic: \"control\", payload: \"queue\"}, {topic: \"control\", payload: \"open\"}, debug]\n }\n if (current_color_temp == circadian_mireds &&\n current_brightness != circadian_brightness){\n return [{topic: \"control\", payload: \"open\"}, {topic: \"control\", payload: \"queue\"}, debug]\n }\n if (current_color_temp != circadian_mireds && \n current_brightness != circadian_brightness){\n return [{topic: \"control\", payload: \"queue\"}, {topic: \"control\", payload: \"queue\"}, debug]\n }\n }\n \nif (msg.data.old_state.state == \"off\" && msg.data.new_state.state == \"on\"){\n return [ { topic: \"control\", payload: \"open\", data: {color_temp: circadian_mireds}},\n { topic: \"control\", payload: \"open\", data: {brightness: circadian_brightness}},\n debug ]}\n\n/* payload.brightness */\n\nif (msg.data.old_state.state == \"on\" && msg.data.new_state.state == \"off\"){\n return [{ topic: \"control\", payload: \"queue\" }, { topic: \"control\", payload: \"queue\"}, debug ]\n }\n\nreturn [null, null, debug]\n\n","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":140,"wires":[[],[],[]]},{"id":"ae8af5aa195ee960","type":"debug","z":"03454e69d1fb38da","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"$globalContext('nr_circadian_mireds')\t","targetType":"jsonata","statusVal":"","statusType":"auto","x":420,"y":260,"wires":[]},{"id":"15d3ba0a712a2f77","type":"debug","z":"03454e69d1fb38da","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"$globalContext('nr_circadian_brightness')\t","targetType":"jsonata","statusVal":"","statusType":"auto","x":420,"y":220,"wires":[]},{"id":"60a4dca9.c29d14","type":"api-call-service","z":"7ea0620.a243ca","name":"Light 1","server":"c879ac61.99cd1","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.office_light_1"],"data":"{\t \"brightness\": payload.brightness,\t \"color_temp\": payload.color_temp\t}","dataType":"jsonata","mergeContext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1250,"y":440,"wires":[[]]},{"id":"3863e49219f2c06c","type":"api-call-service","z":"7ea0620.a243ca","name":"Light 2","server":"c879ac61.99cd1","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.office_light_2"],"data":"{\t \"brightness\": payload.brightness,\t \"color_temp\": payload.color_temp}","dataType":"jsonata","mergeContext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1250,"y":700,"wires":[[]]},{"id":"c5c6137c20db841c","type":"api-call-service","z":"7ea0620.a243ca","name":"Light 3","server":"c879ac61.99cd1","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.office_light_3"],"data":"{\t \"brightness\": payload.brightness,\t \"color_temp\": payload.color_temp\t}","dataType":"jsonata","mergeContext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1250,"y":960,"wires":[[]]},{"id":"5953dc0a6a10c314","type":"server-state-changed","z":"7ea0620.a243ca","name":"Office Color","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_color_office","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"topic","propertyType":"msg","value":"control","valueType":"str"},{"property":"payload","propertyType":"msg","value":"$entity().state = \"on\" ? \"open\" : \"queue\"","valueType":"jsonata"}],"x":110,"y":620,"wires":[["cd1e6d98e1856bda"]]},{"id":"3728361be31f9153","type":"server-state-changed","z":"7ea0620.a243ca","name":"Office Brightness","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_brightness_office","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"$entity().state = \"on\" ? \"open\" : \"queue\"","valueType":"jsonata"},{"property":"topic","propertyType":"msg","value":"control","valueType":"str"}],"x":120,"y":900,"wires":[["f66d24bc98a1e3de"]]},{"id":"5fcdbdfcad60b453","type":"q-gate","z":"7ea0620.a243ca","name":"color_temp 2","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"1","keepNewest":true,"qToggle":true,"persist":true,"storeName":"file","x":810,"y":720,"wires":[["b36ec2b3b096f8d6"]]},{"id":"4b80d3dcd0dcb9fa","type":"link in","z":"7ea0620.a243ca","name":"Office Light 3 Color ","links":["a8f21399bc702421","cd1e6d98e1856bda","fd3507f41d911080","3c70d73a047e84c9"],"x":677,"y":920,"wires":[["205fbe9a86620c6f"]]},{"id":"bb5ea6235f3f465f","type":"link in","z":"7ea0620.a243ca","name":"Office Light 2 Brightness ","links":["a8f21399bc702421","f66d24bc98a1e3de","342a41b7269be8e5","8f139b7a2e1e1072"],"x":676,"y":840,"wires":[["0f7d743cce7739ef"]]},{"id":"5731df33e0ef2e56","type":"q-gate","z":"7ea0620.a243ca","name":"brightness 2","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"1","keepNewest":true,"qToggle":true,"persist":true,"storeName":"file","x":810,"y":780,"wires":[["b36ec2b3b096f8d6"]]},{"id":"f38eeefba2af67ce","type":"q-gate","z":"7ea0620.a243ca","name":"color_temp 3","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"1","keepNewest":true,"qToggle":true,"persist":true,"storeName":"file","x":810,"y":980,"wires":[["1bd0cac097924a72"]]},{"id":"9dfb80638a8e3d73","type":"q-gate","z":"7ea0620.a243ca","name":"color_temp 1","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"1","keepNewest":true,"qToggle":true,"persist":true,"storeName":"file","x":810,"y":460,"wires":[["ee6e3c5a8750dbd3"]]},{"id":"22570f7cadf11491","type":"q-gate","z":"7ea0620.a243ca","name":"brightness 3","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"1","keepNewest":true,"qToggle":true,"persist":true,"storeName":"file","x":810,"y":1040,"wires":[["1bd0cac097924a72"]]},{"id":"1c0b19f6eaee2844","type":"q-gate","z":"7ea0620.a243ca","name":"brightness 1","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"1","keepNewest":true,"qToggle":true,"persist":true,"storeName":"file","x":810,"y":520,"wires":[["ee6e3c5a8750dbd3"]]},{"id":"448f5e6c691dccc4","type":"server-state-changed","z":"7ea0620.a243ca","name":"Light 1","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.office_light_1","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":"2","forType":"num","forUnits":"seconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"}],"x":90,"y":500,"wires":[["54596c6ee70cd5bc"],["2758054b03a4112e"]]},{"id":"4193dc61304afe65","type":"link in","z":"7ea0620.a243ca","name":"Office Light 3 Brightness ","links":["a8f21399bc702421","f66d24bc98a1e3de","8a2b61b96870ef33","3c70d73a047e84c9"],"x":677,"y":1100,"wires":[["eeacce7f3575f983"]]},{"id":"2a3d1ccf39330b28","type":"link in","z":"7ea0620.a243ca","name":"Office Light 1 Color","links":["9c85a0510c0826d0","a8f21399bc702421","b05b2fb283191597","cd1e6d98e1856bda"],"x":675,"y":400,"wires":[["afacf51113b59757"]]},{"id":"f6f58ab7e35f5688","type":"link in","z":"7ea0620.a243ca","name":"Office Light 2 Color","links":["a8f21399bc702421","cd1e6d98e1856bda","46b905fb1f10d588","8f139b7a2e1e1072"],"x":676,"y":660,"wires":[["b3ed481a8b87ca83"]]},{"id":"4f8d44ef76bac586","type":"link in","z":"7ea0620.a243ca","name":"Office Light 1 Brightness","links":["9c85a0510c0826d0","a8f21399bc702421","a92499638df3f0ae","f66d24bc98a1e3de"],"x":675,"y":580,"wires":[["6b84a041a8d0dacb"]]},{"id":"ae45a60691ab54fc","type":"server-state-changed","z":"7ea0620.a243ca","name":"Light 2","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.office_light_2","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":"2","forType":"num","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"}],"x":90,"y":760,"wires":[["913f16d48e88e4a5"],["6ab4a1291df30475"]]},{"id":"900f6d3a6843c9d4","type":"server-state-changed","z":"7ea0620.a243ca","name":"Light 3","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.office_light_3","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":"2","forType":"num","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"data","propertyType":"msg","value":"","valueType":"eventData"}],"x":90,"y":1020,"wires":[["c2e7a75505a9e6e6"],["5e7dad3531a9ab92"]]},{"id":"f66d24bc98a1e3de","type":"link out","z":"7ea0620.a243ca","name":"Office Brightness","mode":"link","links":["4193dc61304afe65","4f8d44ef76bac586","bb5ea6235f3f465f"],"x":255,"y":900,"wires":[]},{"id":"cd1e6d98e1856bda","type":"link out","z":"7ea0620.a243ca","name":"Office Color","mode":"link","links":["2a3d1ccf39330b28","4b80d3dcd0dcb9fa","f6f58ab7e35f5688"],"x":255,"y":620,"wires":[]},{"id":"f75a6792daaeb0b4","type":"comment","z":"7ea0620.a243ca","name":"Office","info":"","x":70,"y":300,"wires":[]},{"id":"ee6e3c5a8750dbd3","type":"join","z":"7ea0620.a243ca","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"2","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":970,"y":480,"wires":[["ae9faf4f99f5df6b"]]},{"id":"b36ec2b3b096f8d6","type":"join","z":"7ea0620.a243ca","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"2","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":970,"y":740,"wires":[["4449a34d85b294de"]]},{"id":"1bd0cac097924a72","type":"join","z":"7ea0620.a243ca","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"2","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":970,"y":1000,"wires":[["5e4f3934b95b1e9e"]]},{"id":"2758054b03a4112e","type":"subflow:03454e69d1fb38da","z":"7ea0620.a243ca","name":"Office Light 1 Control","x":400,"y":496,"wires":[["b05b2fb283191597"],["a92499638df3f0ae"],[]]},{"id":"6ab4a1291df30475","type":"subflow:03454e69d1fb38da","z":"7ea0620.a243ca","name":"Office Light 2 Control","x":400,"y":756,"wires":[["46b905fb1f10d588"],["342a41b7269be8e5"],[]]},{"id":"5e7dad3531a9ab92","type":"subflow:03454e69d1fb38da","z":"7ea0620.a243ca","name":"Office Light 3 Control","x":400,"y":1015,"wires":[["fd3507f41d911080"],["8a2b61b96870ef33"],[]]},{"id":"43c2e1ab9d4c3a33","type":"link in","z":"7ea0620.a243ca","name":"Office Light 1 Color Temp q-gate","links":["934e0600896a7adb","14e63aec201e0a1d"],"x":675,"y":460,"wires":[["9dfb80638a8e3d73"]]},{"id":"3055458e27486427","type":"link in","z":"7ea0620.a243ca","name":"Office Light 1 Brightness q-gate","links":["b1ee887a5f59e581","a05475178f653842"],"x":675,"y":520,"wires":[["1c0b19f6eaee2844"]]},{"id":"b05b2fb283191597","type":"link out","z":"7ea0620.a243ca","name":"Office Light 1 Color Control","mode":"link","links":["2a3d1ccf39330b28"],"x":575,"y":460,"wires":[]},{"id":"a92499638df3f0ae","type":"link out","z":"7ea0620.a243ca","name":"Office Light 1 Brightness Control","mode":"link","links":["4f8d44ef76bac586"],"x":575,"y":522,"wires":[]},{"id":"166c734b13052fb7","type":"link out","z":"7ea0620.a243ca","name":"Office Light 2 Color Control","mode":"link","links":["9d3d2931ff09f30e"],"x":575,"y":660,"wires":[]},{"id":"fe02e119919f1fbf","type":"link out","z":"7ea0620.a243ca","name":"Office Light 2 Brightness Control","mode":"link","links":["df433767e85260dc"],"x":575,"y":840,"wires":[]},{"id":"9d3d2931ff09f30e","type":"link in","z":"7ea0620.a243ca","name":"Office Light 2 Color Temp q-gate","links":["166c734b13052fb7","934e0600896a7adb"],"x":676,"y":720,"wires":[["5fcdbdfcad60b453"]]},{"id":"df433767e85260dc","type":"link in","z":"7ea0620.a243ca","name":"Office Light 2 Brightness q-gate","links":["b1ee887a5f59e581","fe02e119919f1fbf"],"x":676,"y":780,"wires":[["5731df33e0ef2e56"]]},{"id":"babbee9d013605d2","type":"link out","z":"7ea0620.a243ca","name":"Office Light 2 Color Control","mode":"link","links":["46442d133be6f963"],"x":575,"y":920,"wires":[]},{"id":"5da1ef5db9218f1e","type":"link out","z":"7ea0620.a243ca","name":"Office Light 2 Brightness Control","mode":"link","links":["4ccd12c7e9fa28f9"],"x":575,"y":1100,"wires":[]},{"id":"46442d133be6f963","type":"link in","z":"7ea0620.a243ca","name":"Office Light 3 Color Temp q-gate","links":["934e0600896a7adb","babbee9d013605d2"],"x":677,"y":980,"wires":[["f38eeefba2af67ce"]]},{"id":"4ccd12c7e9fa28f9","type":"link in","z":"7ea0620.a243ca","name":"Office Light 3 Brightness q-gate","links":["5da1ef5db9218f1e","b1ee887a5f59e581"],"x":677,"y":1040,"wires":[["22570f7cadf11491"]]},{"id":"ae9faf4f99f5df6b","type":"api-current-state","z":"7ea0620.a243ca","name":"On?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.office_light_1","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1090,"y":480,"wires":[["60a4dca9.c29d14"],["d96a7d6cd4f42087"]]},{"id":"4449a34d85b294de","type":"api-current-state","z":"7ea0620.a243ca","name":"On?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.office_light_2","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1090,"y":740,"wires":[["3863e49219f2c06c"],["d5a0d787dd0474e6"]]},{"id":"5e4f3934b95b1e9e","type":"api-current-state","z":"7ea0620.a243ca","name":"On?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.office_light_3","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1090,"y":1000,"wires":[["c5c6137c20db841c"],["d17fef61a294583d"]]},{"id":"d96a7d6cd4f42087","type":"change","z":"7ea0620.a243ca","name":"Queue","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"queue","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":540,"wires":[["9c85a0510c0826d0"]]},{"id":"9c85a0510c0826d0","type":"link out","z":"7ea0620.a243ca","name":"Office Light 1 is off","mode":"link","links":["2a3d1ccf39330b28","4f8d44ef76bac586"],"x":1335,"y":540,"wires":[]},{"id":"d5a0d787dd0474e6","type":"change","z":"7ea0620.a243ca","name":"Queue","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"queue","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":800,"wires":[["8f139b7a2e1e1072"]]},{"id":"8f139b7a2e1e1072","type":"link out","z":"7ea0620.a243ca","name":"Office Light 2 is off","mode":"link","links":["bb5ea6235f3f465f","f6f58ab7e35f5688"],"x":1335,"y":800,"wires":[]},{"id":"3c70d73a047e84c9","type":"link out","z":"7ea0620.a243ca","name":"Office Light 3 is off","mode":"link","links":["4193dc61304afe65","4b80d3dcd0dcb9fa"],"x":1335,"y":1060,"wires":[]},{"id":"d17fef61a294583d","type":"change","z":"7ea0620.a243ca","name":"Queue","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"queue","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":1060,"wires":[["3c70d73a047e84c9"]]},{"id":"afacf51113b59757","type":"rbe","z":"7ea0620.a243ca","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":400,"wires":[["9dfb80638a8e3d73","ce3850c7f2312b5d"]]},{"id":"6b84a041a8d0dacb","type":"rbe","z":"7ea0620.a243ca","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":580,"wires":[["1c0b19f6eaee2844","84f4c44c1c9a6270"]]},{"id":"14e63aec201e0a1d","type":"link out","z":"7ea0620.a243ca","name":"Office Light 1 Color Temp Payload","mode":"link","links":["43c2e1ab9d4c3a33"],"x":575,"y":400,"wires":[]},{"id":"a05475178f653842","type":"link out","z":"7ea0620.a243ca","name":"Office Light 1 Brightness Payload","mode":"link","links":["3055458e27486427"],"x":575,"y":580,"wires":[]},{"id":"46b905fb1f10d588","type":"link out","z":"7ea0620.a243ca","name":"Office Light 2 Color Control","mode":"link","links":["f6f58ab7e35f5688"],"x":575,"y":720,"wires":[]},{"id":"342a41b7269be8e5","type":"link out","z":"7ea0620.a243ca","name":"Office Light 2 Brightness Control","mode":"link","links":["bb5ea6235f3f465f"],"x":575,"y":780,"wires":[]},{"id":"fd3507f41d911080","type":"link out","z":"7ea0620.a243ca","name":"Office Light 2 Color Control","mode":"link","links":["4b80d3dcd0dcb9fa"],"x":575,"y":980,"wires":[]},{"id":"8a2b61b96870ef33","type":"link out","z":"7ea0620.a243ca","name":"Office Light 2 Brightness Control","mode":"link","links":["4193dc61304afe65"],"x":575,"y":1040,"wires":[]},{"id":"b3ed481a8b87ca83","type":"rbe","z":"7ea0620.a243ca","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":660,"wires":[["5fcdbdfcad60b453","3de6e7f4107c66eb"]]},{"id":"0f7d743cce7739ef","type":"rbe","z":"7ea0620.a243ca","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":840,"wires":[["5731df33e0ef2e56","a1670fdb6018f8c0"]]},{"id":"205fbe9a86620c6f","type":"rbe","z":"7ea0620.a243ca","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":920,"wires":[["f38eeefba2af67ce","4e673c3eb55813fc"]]},{"id":"eeacce7f3575f983","type":"rbe","z":"7ea0620.a243ca","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":1100,"wires":[["22570f7cadf11491","7cbd2d1ed4231ae3"]]},{"id":"ce3850c7f2312b5d","type":"ha-binary-sensor","z":"7ea0620.a243ca","name":"Light 1 Color Control","entityConfig":"11dfa753a1a2cd05","version":0,"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1020,"y":420,"wires":[[]]},{"id":"84f4c44c1c9a6270","type":"ha-binary-sensor","z":"7ea0620.a243ca","name":"Light 1 Brightness Control","entityConfig":"94a02ed09a89725d","version":0,"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1030,"y":540,"wires":[[]]},{"id":"3de6e7f4107c66eb","type":"ha-binary-sensor","z":"7ea0620.a243ca","name":"Light 2 Color Control","entityConfig":"7b9a79c482830d5b","version":0,"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1020,"y":680,"wires":[[]]},{"id":"a1670fdb6018f8c0","type":"ha-binary-sensor","z":"7ea0620.a243ca","name":"Light 2 Brightness Control","entityConfig":"6e90b1ffee7f80b8","version":0,"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1030,"y":800,"wires":[[]]},{"id":"4e673c3eb55813fc","type":"ha-binary-sensor","z":"7ea0620.a243ca","name":"Light 3 Color Control","entityConfig":"e847b97612b57cde","version":0,"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1020,"y":940,"wires":[[]]},{"id":"7cbd2d1ed4231ae3","type":"ha-binary-sensor","z":"7ea0620.a243ca","name":"Light 3 Brightness Control","entityConfig":"1489ae336f7022ab","version":0,"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1030,"y":1060,"wires":[[]]},{"id":"c2e7a75505a9e6e6","type":"trigger","z":"7ea0620.a243ca","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"1","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":220,"y":1000,"wires":[["5e7dad3531a9ab92"]]},{"id":"913f16d48e88e4a5","type":"trigger","z":"7ea0620.a243ca","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"1","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":220,"y":740,"wires":[["6ab4a1291df30475"]]},{"id":"54596c6ee70cd5bc","type":"trigger","z":"7ea0620.a243ca","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"1","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":220,"y":480,"wires":[["2758054b03a4112e"]]},{"id":"c879ac61.99cd1","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"11dfa753a1a2cd05","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"","name":"binary sensor config for Light 1 Color Control","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Office Light 1 Color Control"},{"property":"device_class","value":"opening"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"94a02ed09a89725d","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"","name":"binary sensor config for Light 1 Brightness Control","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Office Light 1 Brightness Control"},{"property":"device_class","value":"opening"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"7b9a79c482830d5b","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"","name":"binary sensor config for Light 2 Color Control","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Office Light 2 Color Control"},{"property":"device_class","value":"opening"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"6e90b1ffee7f80b8","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"","name":"binary sensor config for Light 2 Brightness Control","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Office Light 2 Brightness Control"},{"property":"device_class","value":"opening"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"e847b97612b57cde","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"","name":"binary sensor config for Light 3 Color Control","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Office Light 3 Color Control"},{"property":"device_class","value":"opening"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"1489ae336f7022ab","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"","name":"binary sensor config for Light 3 Brightness Control","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Office Light 3 Brightness Control"},{"property":"device_class","value":"opening"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true}]
(part 3)
[{"id":"03454e69d1fb38da","type":"subflow","name":"Color / Brightness","info":"Color / Brightness Control commands for q-gate node","category":"","in":[{"x":340,"y":140,"wires":[{"id":"e9076938078efe18"}]}],"out":[{"x":640,"y":60,"wires":[{"id":"e9076938078efe18","port":0}]},{"x":640,"y":120,"wires":[{"id":"e9076938078efe18","port":1}]},{"x":640,"y":180,"wires":[{"id":"e9076938078efe18","port":2}]}],"env":[],"meta":{},"color":"#DDAA99","status":{"x":640,"y":240,"wires":[]}},{"id":"e9076938078efe18","type":"function","z":"03454e69d1fb38da","name":"","func":"var entity_id = msg.data.entity_id\nvar current_brightness = msg.data.new_state.attributes.brightness;\nvar current_color_temp = msg.data.new_state.attributes.color_temp;\nvar circadian_mireds = global.get(\"nr_circadian_mireds\");\nvar circadian_brightness = global.get(\"nr_circadian_brightness\");\n/*\nvar calculated_brightness_state = Math.round(circadian_brightness * 0.996078431);\nif (calculated_brightness_state == 254) {calculated_brightness_state = 255}\n*/\ncircadian_brightness = Math.round(circadian_brightness * 0.996078431) + Math.floor(circadian_brightness/255);\n\nvar debug = \n {\n \"Entity\": entity_id,\n \"Old color\": msg.data.old_state.attributes.color_temp,\n \"New color\": msg.data.new_state.attributes.color_temp,\n \"Current color_temp\": current_color_temp,\n \"Circadian mireds\": circadian_mireds,\n \"Old brightness\": msg.data.old_state.attributes.brightness,\n \"New brightness\": msg.data.new_state.attributes.brightness,\n \"Current brightness\": current_brightness,\n \"Circadian brightness\": circadian_brightness\n }\n\nif (msg.data.old_state.state == \"on\" && msg.data.new_state.state == \"on\"){\n\n if (current_color_temp == circadian_mireds &&\n current_brightness == circadian_brightness){\n return [{topic: \"control\", payload: \"open\"}, {topic: \"control\", payload: \"open\"}, debug]\n }\n if (current_color_temp != circadian_mireds &&\n current_brightness == circadian_brightness){\n return [{topic: \"control\", payload: \"queue\"}, {topic: \"control\", payload: \"open\"}, debug]\n }\n if (current_color_temp == circadian_mireds &&\n current_brightness != circadian_brightness){\n return [{topic: \"control\", payload: \"open\"}, {topic: \"control\", payload: \"queue\"}, debug]\n }\n if (current_color_temp != circadian_mireds && \n current_brightness != circadian_brightness){\n return [{topic: \"control\", payload: \"queue\"}, {topic: \"control\", payload: \"queue\"}, debug]\n }\n }\n \nif (msg.data.old_state.state == \"off\" && msg.data.new_state.state == \"on\"){\n return [ { topic: \"control\", payload: \"open\", data: {color_temp: circadian_mireds}},\n { topic: \"control\", payload: \"open\", data: {brightness: circadian_brightness}},\n debug ]}\n\n/* payload.brightness */\n\nif (msg.data.old_state.state == \"on\" && msg.data.new_state.state == \"off\"){\n return [{ topic: \"control\", payload: \"queue\" }, { topic: \"control\", payload: \"queue\"}, debug ]\n }\n\nreturn [null, null, debug]\n\n","outputs":3,"noerr":0,"initialize":"","finalize":"","libs":[],"x":480,"y":140,"wires":[[],[],[]]},{"id":"ae8af5aa195ee960","type":"debug","z":"03454e69d1fb38da","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"$globalContext('nr_circadian_mireds')\t","targetType":"jsonata","statusVal":"","statusType":"auto","x":420,"y":260,"wires":[]},{"id":"15d3ba0a712a2f77","type":"debug","z":"03454e69d1fb38da","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"$globalContext('nr_circadian_brightness')\t","targetType":"jsonata","statusVal":"","statusType":"auto","x":420,"y":220,"wires":[]},{"id":"1f25b966d1c6291c","type":"api-call-service","z":"7ea0620.a243ca","name":"Lamp 1","server":"c879ac61.99cd1","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.bedroom_lamp_1"],"data":"{\t \"brightness\": payload.brightness,\t \"color_temp\": payload.color_temp\t}","dataType":"jsonata","mergeContext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1260,"y":1280,"wires":[[]]},{"id":"c03d3dd29a831494","type":"api-call-service","z":"7ea0620.a243ca","name":"Lamp 2","server":"c879ac61.99cd1","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["light.bedroom_lamp_2"],"data":"{\t \"brightness\": payload.brightness,\t \"color_temp\": payload.color_temp\t}","dataType":"jsonata","mergeContext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1260,"y":1540,"wires":[[]]},{"id":"e707970223078820","type":"q-gate","z":"7ea0620.a243ca","name":"color_temp","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"1","keepNewest":true,"qToggle":true,"persist":true,"storeName":"file","x":810,"y":1300,"wires":[["c3a4bf2a08ab0d24"]]},{"id":"0e8b24ed04b4935a","type":"q-gate","z":"7ea0620.a243ca","name":"brightness","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"1","keepNewest":true,"qToggle":true,"persist":true,"storeName":"file","x":810,"y":1360,"wires":[["c3a4bf2a08ab0d24"]]},{"id":"aa436d4aef53ba79","type":"q-gate","z":"7ea0620.a243ca","name":"color_temp","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"1","keepNewest":true,"qToggle":true,"persist":true,"storeName":"file","x":810,"y":1560,"wires":[["8ebc916034ac07d2"]]},{"id":"500b7e47055ea28c","type":"q-gate","z":"7ea0620.a243ca","name":"brightness","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"","dropCmd":"","statusCmd":"","maxQueueLength":"1","keepNewest":true,"qToggle":true,"persist":true,"storeName":"file","x":810,"y":1620,"wires":[["8ebc916034ac07d2"]]},{"id":"9368eeec1b7c880b","type":"server-state-changed","z":"7ea0620.a243ca","name":"Bedroom Color","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_color_bedroom","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"$entity().state = \"on\" ? \"open\" : \"queue\"","valueType":"jsonata"},{"property":"topic","propertyType":"msg","value":"control","valueType":"str"}],"x":126,"y":1420,"wires":[["b8c9f63fc805cae0"]]},{"id":"7d8a0deef287ad2c","type":"server-state-changed","z":"7ea0620.a243ca","name":"Bedroom Brightness","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_brightness_bedroom","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"$entity().state = \"on\" ? \"open\" : \"queue\"","valueType":"jsonata"},{"property":"topic","propertyType":"msg","value":"control","valueType":"str"}],"x":116,"y":1500,"wires":[["1b32eb0358a988cf"]]},{"id":"4ec21b16da174db6","type":"server-state-changed","z":"7ea0620.a243ca","name":"Circadian Bedroom","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_bedroom","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":false,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":115,"y":1260,"wires":[["bdf91016c6a90f48"]]},{"id":"4593a42aa239dadd","type":"link in","z":"7ea0620.a243ca","name":"Bedroom Lamp 1 Color ","links":["b8c9f63fc805cae0","de1be3f3be4af558","8cac123ecbd59c2a","5ba9a3e3ab65f8bd"],"x":685,"y":1240,"wires":[["6c8916dc559fa2b8"]]},{"id":"bfc5edc53296a8c4","type":"link in","z":"7ea0620.a243ca","name":"Bedroom Lamp 2 Brightness","links":["1b32eb0358a988cf","de1be3f3be4af558","4464da13ff770cfb","205b0b229ef257b4"],"x":685,"y":1680,"wires":[["ae8874f2aac7a030"]]},{"id":"b8c9f63fc805cae0","type":"link out","z":"7ea0620.a243ca","name":"Bedroom Color","mode":"link","links":["0402eb088ab780b7","f561c90a0e4e6e3c","dcfa43aa5b436092","4593a42aa239dadd","eb0c9865a1d29657"],"x":255,"y":1420,"wires":[]},{"id":"1b32eb0358a988cf","type":"link out","z":"7ea0620.a243ca","name":"Bedroom Brightness","mode":"link","links":["52d70d0a5994999a","1339a4cf83b12cb5","dcfa43aa5b436092","f469dccbd0fea627","bfc5edc53296a8c4"],"x":255,"y":1500,"wires":[]},{"id":"aff2029202c99c40","type":"server-state-changed","z":"7ea0620.a243ca","name":"Lamp 1","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.bedroom_lamp_1","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":"","forType":"num","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"}],"x":70,"y":1340,"wires":[["02becfa85f14f491"],["89f66c95982a2bd8"]]},{"id":"c7ea0a655937976f","type":"server-state-changed","z":"7ea0620.a243ca","name":"Lamp 2","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.bedroom_lamp_2","entityidfiltertype":"exact","outputinitially":true,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":false,"for":"","forType":"num","forUnits":"seconds","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"}],"x":70,"y":1600,"wires":[["087a6decae0adfdc"],["721e357b68403c91"]]},{"id":"eb0c9865a1d29657","type":"link in","z":"7ea0620.a243ca","name":"Bedroom Lamp 2 Color ","links":["b8c9f63fc805cae0","de1be3f3be4af558","3b438055c6a0a6f3","205b0b229ef257b4"],"x":685,"y":1500,"wires":[["791d4cdc42260526"]]},{"id":"f469dccbd0fea627","type":"link in","z":"7ea0620.a243ca","name":"Bedroom Lamp 1 Brightness ","links":["1b32eb0358a988cf","de1be3f3be4af558","42ab613fb5c6826a","5ba9a3e3ab65f8bd"],"x":685,"y":1420,"wires":[["77a72f3ff0be5c23"]]},{"id":"efa13c52c2947471","type":"comment","z":"7ea0620.a243ca","name":"Bedroom","info":"","x":80,"y":1200,"wires":[]},{"id":"c3a4bf2a08ab0d24","type":"join","z":"7ea0620.a243ca","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":970,"y":1320,"wires":[["eb62467f936cc312"]]},{"id":"8ebc916034ac07d2","type":"join","z":"7ea0620.a243ca","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"1","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":970,"y":1580,"wires":[["7dbf53ed6511854f"]]},{"id":"721e357b68403c91","type":"subflow:03454e69d1fb38da","z":"7ea0620.a243ca","name":"Bedroom Lamp 2 Control","x":390,"y":1600,"wires":[["3b438055c6a0a6f3"],["4464da13ff770cfb"],[]]},{"id":"89f66c95982a2bd8","type":"subflow:03454e69d1fb38da","z":"7ea0620.a243ca","name":"Bedroom Lamp 1 Control","x":390,"y":1340,"wires":[["8cac123ecbd59c2a"],["42ab613fb5c6826a"],[]]},{"id":"a52970d03d1f30a5","type":"link in","z":"7ea0620.a243ca","name":"Bedroom Lamp 1 Color Temp q-gate","links":["8a79cf60dd08216b","934e0600896a7adb"],"x":685,"y":1300,"wires":[["e707970223078820"]]},{"id":"d72d56acc2f72b41","type":"link in","z":"7ea0620.a243ca","name":"Bedroom Lamp 1 Brightness q-gate","links":["b1ee887a5f59e581","64e6c7be4a0b5b31"],"x":685,"y":1360,"wires":[["0e8b24ed04b4935a"]]},{"id":"a897dbf21ffb2b4c","type":"link in","z":"7ea0620.a243ca","name":"Bedroom Lamp 2 Color Temp q-gate","links":["934e0600896a7adb","af11162d699c55e1"],"x":685,"y":1560,"wires":[["aa436d4aef53ba79"]]},{"id":"b1137e5488a33dda","type":"link in","z":"7ea0620.a243ca","name":"Bedroom Lamp 2 Brightness q-gate","links":["3add71feb086602c","b1ee887a5f59e581"],"x":685,"y":1620,"wires":[["500b7e47055ea28c"]]},{"id":"eb62467f936cc312","type":"api-current-state","z":"7ea0620.a243ca","name":"On?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.bedroom_lamp_1","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1090,"y":1320,"wires":[["1f25b966d1c6291c"],["a3ac27cec52e9b67"]]},{"id":"7dbf53ed6511854f","type":"api-current-state","z":"7ea0620.a243ca","name":"On?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.bedroom_lamp_2","state_type":"str","blockInputOverrides":false,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1090,"y":1580,"wires":[["c03d3dd29a831494"],["3a6f5d2fa04a41cb"]]},{"id":"a3ac27cec52e9b67","type":"change","z":"7ea0620.a243ca","name":"Queue","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"queue","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":1360,"wires":[["5ba9a3e3ab65f8bd"]]},{"id":"5ba9a3e3ab65f8bd","type":"link out","z":"7ea0620.a243ca","name":"Bedroom Lamp 1 is off","mode":"link","links":["4593a42aa239dadd","f469dccbd0fea627"],"x":1335,"y":1360,"wires":[]},{"id":"3a6f5d2fa04a41cb","type":"change","z":"7ea0620.a243ca","name":"Queue","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"queue","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":1620,"wires":[["205b0b229ef257b4"]]},{"id":"205b0b229ef257b4","type":"link out","z":"7ea0620.a243ca","name":"Bedroom Lamp 2 is off","mode":"link","links":["bfc5edc53296a8c4","eb0c9865a1d29657"],"x":1335,"y":1620,"wires":[]},{"id":"8cac123ecbd59c2a","type":"link out","z":"7ea0620.a243ca","name":"Bedroom Lamp 1 Color Control","mode":"link","links":["4593a42aa239dadd"],"x":575,"y":1300,"wires":[]},{"id":"42ab613fb5c6826a","type":"link out","z":"7ea0620.a243ca","name":"Bedroom Lamp 1 Brightness Control","mode":"link","links":["f469dccbd0fea627"],"x":575,"y":1360,"wires":[]},{"id":"3b438055c6a0a6f3","type":"link out","z":"7ea0620.a243ca","name":"Bedroom Lamp 2 Color Control","mode":"link","links":["eb0c9865a1d29657"],"x":571,"y":1560,"wires":[]},{"id":"4464da13ff770cfb","type":"link out","z":"7ea0620.a243ca","name":"Bedroom Lampt 2 Brightness Control","mode":"link","links":["bfc5edc53296a8c4"],"x":571,"y":1620,"wires":[]},{"id":"77a72f3ff0be5c23","type":"rbe","z":"7ea0620.a243ca","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":1420,"wires":[["0e8b24ed04b4935a","d704b4c9a13f4d48"]]},{"id":"6c8916dc559fa2b8","type":"rbe","z":"7ea0620.a243ca","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":1240,"wires":[["e707970223078820","90a55a2ab28c924e"]]},{"id":"ff3087b8dcdd2855","type":"debug","z":"7ea0620.a243ca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":450,"y":1680,"wires":[]},{"id":"791d4cdc42260526","type":"rbe","z":"7ea0620.a243ca","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":1500,"wires":[["aa436d4aef53ba79","30b9d29469672a08"]]},{"id":"ae8874f2aac7a030","type":"rbe","z":"7ea0620.a243ca","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":790,"y":1680,"wires":[["500b7e47055ea28c","5e650e87ceb4e8d3"]]},{"id":"f3b8dfee687a283f","type":"server-state-changed","z":"7ea0620.a243ca","name":"Hue switch action","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.phillips_hue_switch_action","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off_press_release","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"queue","valueType":"str"},{"property":"topic","propertyType":"msg","value":"control","valueType":"str"}],"x":260,"y":1680,"wires":[["ff3087b8dcdd2855"],[]]},{"id":"bdf91016c6a90f48","type":"api-call-service","z":"7ea0620.a243ca","name":"Color & Brightness","server":"c879ac61.99cd1","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_{{payload}}","areaId":[],"deviceId":[],"entityId":["input_boolean.circadian_lighting_brightness_bedroom","input_boolean.circadian_lighting_color_bedroom"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":335,"y":1260,"wires":[[]]},{"id":"90a55a2ab28c924e","type":"ha-binary-sensor","z":"7ea0620.a243ca","name":"Lamp 1 Color Control","entityConfig":"bf8ec97a8490e71d","version":0,"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1020,"y":1240,"wires":[[]]},{"id":"d704b4c9a13f4d48","type":"ha-binary-sensor","z":"7ea0620.a243ca","name":"Lamp 1 Brightness Control","entityConfig":"a5f0bea5cc1f92db","version":0,"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1040,"y":1420,"wires":[[]]},{"id":"5e650e87ceb4e8d3","type":"ha-binary-sensor","z":"7ea0620.a243ca","name":"Lamp 2 Brightness Control","entityConfig":"6ca0133380208735","version":0,"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1040,"y":1680,"wires":[[]]},{"id":"30b9d29469672a08","type":"ha-binary-sensor","z":"7ea0620.a243ca","name":"Lamp 2 Color Control","entityConfig":"d10a89118eac9c65","version":0,"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":1020,"y":1500,"wires":[[]]},{"id":"087a6decae0adfdc","type":"trigger","z":"7ea0620.a243ca","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"1","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":200,"y":1580,"wires":[["721e357b68403c91"]]},{"id":"02becfa85f14f491","type":"trigger","z":"7ea0620.a243ca","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"1","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":200,"y":1320,"wires":[["89f66c95982a2bd8"]]},{"id":"c879ac61.99cd1","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"bf8ec97a8490e71d","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"","name":"binary sensor config for Lamp 1 Color Control","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Bedroom Lamp 1 Color Control"},{"property":"device_class","value":"opening"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"a5f0bea5cc1f92db","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"","name":"binary sensor config for Lamp 1 Brightness Control","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Bedroom Lamp 1 Brightness Control"},{"property":"device_class","value":"opening"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"6ca0133380208735","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"","name":"binary sensor config for Lamp 2 Brightness Control","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Bedroom Lamp 2 Brightness Control"},{"property":"device_class","value":"opening"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true},{"id":"d10a89118eac9c65","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"","name":"binary sensor config for Lamp 2 Color Control","version":6,"entityType":"binary_sensor","haConfig":[{"property":"name","value":"Bedroom Lamp 2 Color Control"},{"property":"device_class","value":"opening"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"resend":true}]
Circadian Calculator subflow
[{"id":"5de89261.4fb97c","type":"switch","z":"e812678d.651e28","name":"curve switch","property":"payload.times_of_day.active.name","propertyType":"msg","rules":[{"t":"eq","v":"night","vt":"str"},{"t":"eq","v":"morning","vt":"str"},{"t":"eq","v":"day","vt":"str"},{"t":"eq","v":"evening","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":250,"y":220,"wires":[["ba17c1e6.e6f58","840431b7.eeefc"],["e5bb5a04.a33948","d4d99259.d0d7e"],["7c0f0774.90adf8","6ac1af7.dddb15"],["23b260f9.19f78","a907f5f4.0bf488"]]},{"id":"ba17c1e6.e6f58","type":"spline-curve","z":"e812678d.651e28","name":"night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.3},{"x":0.333,"y":0.037},{"x":0.477,"y":0},{"x":0.783,"y":0},{"x":1,"y":0}],"x":490,"y":80,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"e5bb5a04.a33948","type":"spline-curve","z":"e812678d.651e28","name":"morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.01},{"x":0.132,"y":0.01},{"x":0.269,"y":0.027},{"x":0.449,"y":0.124},{"x":0.676,"y":0.334},{"x":1,"y":0.75}],"x":500,"y":120,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"23b260f9.19f78","type":"spline-curve","z":"e812678d.651e28","name":"evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.036,"y":0.78},{"x":0.176,"y":0.63},{"x":1,"y":0.3}],"x":500,"y":200,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"7c0f0774.90adf8","type":"spline-curve","z":"e812678d.651e28","name":"daylight curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.744},{"x":0.03,"y":0.838},{"x":0.097,"y":0.941},{"x":0.183,"y":1},{"x":0.86,"y":0.995},{"x":0.943,"y":0.931},{"x":1,"y":0.85}],"x":500,"y":160,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"840431b7.eeefc","type":"spline-curve","z":"e812678d.651e28","name":"night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.5},{"x":0.067,"y":0.368},{"x":0.133,"y":0.265},{"x":0.27,"y":0.171},{"x":0.333,"y":0.16},{"x":0.506,"y":0.124},{"x":0.606,"y":0}],"x":490,"y":240,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"d4d99259.d0d7e","type":"spline-curve","z":"e812678d.651e28","name":"morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":0.42,"y":0.018},{"x":0.54,"y":0.051},{"x":0.587,"y":0.101},{"x":0.817,"y":0.675},{"x":1,"y":0.85}],"x":500,"y":280,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"a907f5f4.0bf488","type":"spline-curve","z":"e812678d.651e28","name":"evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.787,"y":0.598},{"x":1,"y":0.5}],"x":500,"y":360,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"6ac1af7.dddb15","type":"spline-curve","z":"e812678d.651e28","name":"daylight curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.123,"y":0.927},{"x":0.5,"y":1},{"x":0.92,"y":0.904},{"x":1,"y":0.85}],"x":500,"y":320,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"40de744.1e2ca8c","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"254","action":"clamp","round":true,"property":"payload","name":"","x":710,"y":100,"wires":[[]]},{"id":"c26bdcca.eb483","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"2000","maxout":"3500","action":"clamp","round":true,"property":"payload","name":"","x":730,"y":320,"wires":[[]]},{"id":"aa4b86d8.b17118","type":"sun-position","z":"e812678d.651e28","name":"","positionConfig":"31826811.22a458","rules":[],"onlyOnChange":"true","topic":"","outputs":1,"start":"","startType":"none","startOffset":0,"startOffsetType":"num","startOffsetMultiplier":60000,"end":"","endType":"none","endOffset":0,"endOffsetType":"num","endOffsetMultiplier":60000,"x":210,"y":80,"wires":[["717191f7a71b0df4"]]},{"id":"15b473ec45fa7fc4","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"100","action":"clamp","round":true,"property":"payload","name":"","x":710,"y":160,"wires":[[]]},{"id":"6f365d7d05905955","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"370","maxout":"154","action":"clamp","round":true,"property":"payload","name":"","x":720,"y":260,"wires":[[]]},{"id":"717191f7a71b0df4","type":"function","z":"e812678d.651e28","name":"Times of Day","func":"var newmsg = JSON.parse(JSON.stringify(msg));\nnewmsg.payload.times_of_day = {};\n\nconst processTimeOfDay = function(nme, obj, name_start, name_end) {\n var ret = {};\n ret.name = nme;\n ret.start = obj.times[name_start].ts;\n ret.end = obj.times[name_end].ts;\n ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);\n \n \n // to cover range starting before midnight and ending after it.\n if (ret.start > ret.end)\n {\n var a;\n\n // before midnight\n if (ret.start < obj.ts) \n {\n a = new Date(ret.end);\n a.setUTCDate(a.getUTCDate() + 1);\n ret.end = a.getTime();\n \n \n }\n else if (ret.end > obj.ts) \n {\n a = new Date(ret.start);\n a.setUTCDate(a.getUTCDate() - 1);\n ret.start = a.getTime();\n\n }\n\n }\n \n ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);\n \n obj.times_of_day[nme] = ret;\n if (ret.start <= obj.ts && obj.ts < ret.end ) obj.times_of_day.active = ret;\n}\n\n\nprocessTimeOfDay('night', newmsg.payload, \"astronomicalDusk\", \"astronomicalDawn\");\nprocessTimeOfDay('morning', newmsg.payload, \"astronomicalDawn\", \"goldenHourDawnEnd\");\nprocessTimeOfDay('day', newmsg.payload, \"goldenHourDawnEnd\", \"sunsetStart\");\nprocessTimeOfDay('evening', newmsg.payload, \"sunsetStart\", \"astronomicalDusk\");\n\n\nreturn newmsg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":140,"wires":[["5de89261.4fb97c"]]},{"id":"31826811.22a458","type":"position-config","name":"Home Location","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12"}]
Thank you very much!
This is a cool function! Wish I had it a year or more ago! Wrote all kinds of logic to determine if light had been manually controlled vs system controlled!
Here is my new coding using most of @TEF2one 's logic. I reverted to my original circadian subroutine though.
[{"id":"cf82d4d1d0e8c57e","type":"subflow","name":"Sub User","info":"","category":"","in":[{"x":300,"y":140,"wires":[{"id":"f3af6dc1e0a0cb9a"}]}],"out":[{"x":1040,"y":140,"wires":[{"id":"5a3ffda74d2750d5","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","icon":"font-awesome/fa-user-circle-o"},{"id":"78038ba6f06d84ed","type":"file in","z":"cf82d4d1d0e8c57e","name":"auth","filename":"/config/.storage/auth","filenameType":"str","format":"utf8","chunk":false,"sendError":false,"encoding":"none","allProps":false,"x":510,"y":140,"wires":[["c7deb9c44ddb1273"]]},{"id":"c7deb9c44ddb1273","type":"json","z":"cf82d4d1d0e8c57e","name":"","property":"payload","action":"obj","pretty":false,"x":630,"y":140,"wires":[["797add51dba1077e"]]},{"id":"797add51dba1077e","type":"function","z":"cf82d4d1d0e8c57e","name":"Set user_system","func":"var user_id = msg.data.context.user_id;\n//var user_id = data.event.new_state.context.user_id;\nvar user_name = \"\";\nvar user_system = null;\n\nfor (var i = 0; i < msg.payload.data.users.length; i++) {\n \n var user = msg.payload.data.users[i];\n \n console.log(user.id);\n \n if (user.id == user_id) {\n user_name = user.name;\n user_system = user.system_generated;\n break;\n }\n}\nmsg.data.context.user_name = user_name == \"Hass.io\" ? \"Home Assistant\" : user_name;\nmsg.data.context.user_system = user_system;\n\ndelete msg.filename; \nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":790,"y":140,"wires":[["5a3ffda74d2750d5"]]},{"id":"f3af6dc1e0a0cb9a","type":"change","z":"cf82d4d1d0e8c57e","name":"Move","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload","tot":"flow","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":390,"y":140,"wires":[["78038ba6f06d84ed"]]},{"id":"5a3ffda74d2750d5","type":"change","z":"cf82d4d1d0e8c57e","name":"Move","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload","tot":"flow","dc":true}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":140,"wires":[[]]},{"id":"e812678d.651e28","type":"subflow","name":"Circadian Calculator","info":"","category":"time and astro","in":[{"x":80,"y":80,"wires":[{"id":"aa4b86d8.b17118"}]}],"out":[{"x":890,"y":100,"wires":[{"id":"40de744.1e2ca8c","port":0}]},{"x":890,"y":160,"wires":[{"id":"15b473ec45fa7fc4","port":0}]},{"x":930,"y":260,"wires":[{"id":"6f365d7d05905955","port":0}]},{"x":930,"y":320,"wires":[{"id":"c26bdcca.eb483","port":0}]},{"x":490,"y":40,"wires":[{"id":"717191f7a71b0df4","port":0}]}],"env":[],"meta":{},"color":"#FFCC66","inputLabels":["Trigger"],"outputLabels":["Brightness Value","Brightness Percent","Mireds","Kelvin","Times of Day"]},{"id":"5de89261.4fb97c","type":"switch","z":"e812678d.651e28","name":"curve switch","property":"payload.times_of_day.active.name","propertyType":"msg","rules":[{"t":"eq","v":"night","vt":"str"},{"t":"eq","v":"morning","vt":"str"},{"t":"eq","v":"day","vt":"str"},{"t":"eq","v":"evening","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":250,"y":220,"wires":[["ba17c1e6.e6f58","840431b7.eeefc"],["e5bb5a04.a33948","d4d99259.d0d7e"],["7c0f0774.90adf8","6ac1af7.dddb15"],["23b260f9.19f78","a907f5f4.0bf488"]]},{"id":"ba17c1e6.e6f58","type":"spline-curve","z":"e812678d.651e28","name":"night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.3},{"x":0.333,"y":0.037},{"x":0.477,"y":0},{"x":0.783,"y":0},{"x":1,"y":0}],"x":490,"y":80,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"e5bb5a04.a33948","type":"spline-curve","z":"e812678d.651e28","name":"morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.01},{"x":0.132,"y":0.01},{"x":0.269,"y":0.027},{"x":0.449,"y":0.124},{"x":0.676,"y":0.334},{"x":1,"y":0.75}],"x":500,"y":120,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"23b260f9.19f78","type":"spline-curve","z":"e812678d.651e28","name":"evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.036,"y":0.78},{"x":0.176,"y":0.63},{"x":1,"y":0.3}],"x":500,"y":200,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"7c0f0774.90adf8","type":"spline-curve","z":"e812678d.651e28","name":"day curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.744},{"x":0.03,"y":0.838},{"x":0.097,"y":0.941},{"x":0.183,"y":1},{"x":0.86,"y":0.995},{"x":0.943,"y":0.931},{"x":1,"y":0.85}],"x":480,"y":160,"wires":[["40de744.1e2ca8c","15b473ec45fa7fc4"]]},{"id":"840431b7.eeefc","type":"spline-curve","z":"e812678d.651e28","name":"night curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.5},{"x":0.067,"y":0.368},{"x":0.133,"y":0.265},{"x":0.27,"y":0.171},{"x":0.333,"y":0.16},{"x":0.506,"y":0.124},{"x":0.606,"y":0}],"x":490,"y":240,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"d4d99259.d0d7e","type":"spline-curve","z":"e812678d.651e28","name":"morning curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0},{"x":0.42,"y":0.018},{"x":0.54,"y":0.051},{"x":0.587,"y":0.101},{"x":0.817,"y":0.675},{"x":1,"y":0.85}],"x":500,"y":280,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"a907f5f4.0bf488","type":"spline-curve","z":"e812678d.651e28","name":"evening curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.787,"y":0.598},{"x":1,"y":0.5}],"x":500,"y":360,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"6ac1af7.dddb15","type":"spline-curve","z":"e812678d.651e28","name":"day curve","output_key":"","input_key":"payload.times_of_day.active.perc","points":[{"x":0,"y":0.85},{"x":0.123,"y":0.927},{"x":0.5,"y":1},{"x":0.92,"y":0.904},{"x":1,"y":0.85}],"x":480,"y":320,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"40de744.1e2ca8c","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"254","action":"clamp","round":true,"property":"payload","name":"","x":710,"y":100,"wires":[[]]},{"id":"c26bdcca.eb483","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"2700","maxout":"5000","action":"clamp","round":true,"property":"payload","name":"","x":730,"y":320,"wires":[[]]},{"id":"aa4b86d8.b17118","type":"sun-position","z":"e812678d.651e28","name":"","positionConfig":"31826811.22a458","rules":[],"onlyOnChange":"true","topic":"","outputs":1,"start":"","startType":"none","startOffset":0,"startOffsetType":"num","startOffsetMultiplier":60000,"end":"","endType":"none","endOffset":0,"endOffsetType":"num","endOffsetMultiplier":60000,"x":210,"y":80,"wires":[["717191f7a71b0df4"]]},{"id":"15b473ec45fa7fc4","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"100","action":"clamp","round":true,"property":"payload","name":"","x":710,"y":160,"wires":[[]]},{"id":"6f365d7d05905955","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"370","maxout":"200","action":"clamp","round":true,"property":"payload","name":"","x":720,"y":260,"wires":[[]]},{"id":"717191f7a71b0df4","type":"function","z":"e812678d.651e28","name":"Times of Day","func":"var newmsg = JSON.parse(JSON.stringify(msg));\nnewmsg.payload.times_of_day = {};\n\nconst processTimeOfDay = function(nme, obj, name_start, name_end) {\n var ret = {};\n ret.name = nme;\n ret.start = obj.times[name_start].ts;\n ret.end = obj.times[name_end].ts;\n ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);\n \n \n // to cover range starting before midnight and ending after it.\n if (ret.start > ret.end)\n {\n var a;\n\n // before midnight\n if (ret.start < obj.ts) \n {\n a = new Date(ret.end);\n a.setUTCDate(a.getUTCDate() + 1);\n ret.end = a.getTime();\n \n \n }\n else if (ret.end > obj.ts) \n {\n a = new Date(ret.start);\n a.setUTCDate(a.getUTCDate() - 1);\n ret.start = a.getTime();\n\n }\n\n }\n \n ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);\n \n obj.times_of_day[nme] = ret;\n if (ret.start <= obj.ts && obj.ts < ret.end ) obj.times_of_day.active = ret;\n}\n\n\nprocessTimeOfDay('night', newmsg.payload, \"astronomicalDusk\", \"astronomicalDawn\");\nprocessTimeOfDay('morning', newmsg.payload, \"astronomicalDawn\", \"goldenHourDawnEnd\");\nprocessTimeOfDay('day', newmsg.payload, \"goldenHourDawnEnd\", \"sunsetStart\");\nprocessTimeOfDay('evening', newmsg.payload, \"sunsetStart\", \"astronomicalDusk\");\n\n\nreturn newmsg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":140,"wires":[["5de89261.4fb97c"]]},{"id":"31826811.22a458","type":"position-config","name":"Home Location","isValide":"true","longitude":"0","latitude":"0","angleType":"deg","timeZoneOffset":"99","timeZoneDST":"0","stateTimeFormat":"3","stateDateFormat":"12","contextStore":""},{"id":"1f49a77.c544559","type":"subflow","name":"Circadian","info":"Circadian subroutine with no transition element.\nUses Circadian Calculator subflow for brightness and color temp outputs.","category":"","in":[{"x":160,"y":200,"wires":[{"id":"a245da6d.764f18"}]}],"out":[{"x":990,"y":200,"wires":[{"id":"952b93bb.d156e","port":0}]},{"x":590,"y":280,"wires":[{"id":"a245da6d.764f18","port":4}]}],"env":[],"meta":{},"color":"#DDAA99","inputLabels":["Trigger"],"outputLabels":["Circadian Values","Times of Day"]},{"id":"57dc027.0eb3afc","type":"function","z":"1f49a77.c544559","name":"Brightness %","func":"var brightness_pct = msg.payload;\nvar newmsg = \n{\n data: {\n brightness_pct: Math.round(brightness_pct)\n } \n}\nreturn newmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":160,"wires":[["952b93bb.d156e"]]},{"id":"e47bba70.5c8038","type":"function","z":"1f49a77.c544559","name":"Kelvin","func":"var kelvin = msg.payload;\nvar newmsg = \n{\n data: {\n \"kelvin\": kelvin\n } \n}\nreturn newmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":240,"wires":[["952b93bb.d156e"]]},{"id":"a245da6d.764f18","type":"subflow:e812678d.651e28","z":"1f49a77.c544559","name":"","x":360,"y":200,"wires":[["c9e19db7899690b2"],["57dc027.0eb3afc"],["c079be8bd262a5b0"],["e47bba70.5c8038"],[]]},{"id":"952b93bb.d156e","type":"join","z":"1f49a77.c544559","name":"","mode":"custom","build":"merged","property":"data","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":810,"y":200,"wires":[[]]},{"id":"c9e19db7899690b2","type":"function","z":"1f49a77.c544559","name":"Brightness","func":"var brightness = msg.payload;\nvar newmsg = \n{\n data: {\n brightness: Math.round(brightness)\n } \n}\nreturn newmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":120,"wires":[["952b93bb.d156e"]]},{"id":"c079be8bd262a5b0","type":"function","z":"1f49a77.c544559","name":"Mireds","func":"var mireds = msg.payload;\nvar newmsg = \n{\n data: {\n \"color_temp\": mireds\n } \n}\nreturn newmsg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":610,"y":200,"wires":[["952b93bb.d156e"]]},{"id":"ad9d46948c536056","type":"switch","z":"0306219034b546af","name":"Init","property":"msg.payload.timeSinceChangedMs","propertyType":"msg","rules":[{"t":"gte","v":"10000","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":690,"y":360,"wires":[["9dc16ae92629d591"],[]]},{"id":"ea4ca17a545569ee","type":"ha-get-entities","z":"0306219034b546af","d":true,"name":"Once","server":"c879ac61.99cd1","version":0,"rules":[{"property":"entity_id","logic":"includes","value":"light.kitchen_light,light.bathroom_light","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":570,"y":360,"wires":[["ad9d46948c536056"]]},{"id":"0dec1a98d346e902","type":"inject","z":"0306219034b546af","name":"inject","props":[{"p":"payload"}],"repeat":"300","crontab":"","once":true,"onceDelay":"1","topic":"","payload":"","payloadType":"date","x":90,"y":300,"wires":[["d30da4ba93adeee1"]]},{"id":"b9c31155c6cf7608","type":"api-current-state","z":"0306219034b546af","name":"Master","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","entity_id":"input_boolean.flux_master","state_type":"habool","blockInputOverrides":true,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":410,"y":300,"wires":[["e2ec2d83b7f9e08f"],[]]},{"id":"bd6357ea60880b84","type":"server-state-changed","z":"0306219034b546af","name":"Lights","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":["light.bedroom_lamp_1","light.bedroom_lamp_2","light.office_light_1","light.office_light_2","light.office_light_3","light.patio_light"],"entityidfiltertype":"list","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":90,"y":460,"wires":[["d30da4ba93adeee1"],["f49e9eaba1ca405f"]]},{"id":"e2ec2d83b7f9e08f","type":"ha-get-entities","z":"0306219034b546af","name":"Auto","server":"c879ac61.99cd1","version":0,"rules":[{"property":"entity_id","logic":"in_group","value":"light.flux_lights","valueType":"str"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":570,"y":300,"wires":[["73e913c89de5c351"]]},{"id":"3cb8b369e99d9f9c","type":"trigger-state","z":"0306219034b546af","name":"Light Event","server":"c879ac61.99cd1","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":["light.bathroom_light","light.bedroom_lamp_1","light.bedroom_lamp_2","light.himalayan_salt_lamp","light.office_light_1","light.office_light_2","light.office_light_3","light.kitchen_light","light.patio_light"],"entityidfiltertype":"list","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","propertyValue":"new_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"},{"targetType":"this_entity","targetValue":"","propertyType":"previous_state","propertyValue":"old_state.state","comparatorType":"is","comparatorValueDatatype":"str","comparatorValue":"on"}],"inputs":1,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":true,"x":80,"y":560,"wires":[["8241f1dac352e352"],[]]},{"id":"069147755dba2601","type":"change","z":"0306219034b546af","name":"light > input_boolean","rules":[{"t":"change","p":"topic","pt":"msg","from":"^light.","fromt":"re","to":"input_boolean.flux_","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":520,"wires":[["6aa53238df8f4871"]]},{"id":"6aa53238df8f4871","type":"api-call-service","z":"0306219034b546af","name":"Control","server":"c879ac61.99cd1","version":5,"debugenabled":false,"domain":"input_boolean","service":"turn_off","areaId":[],"deviceId":[],"entityId":["{{topic}}"],"data":"","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":980,"y":520,"wires":[[]]},{"id":"f49e9eaba1ca405f","type":"change","z":"0306219034b546af","name":"Reset","rules":[{"t":"set","p":"payload.service","pt":"msg","to":"turn_on","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":230,"y":520,"wires":[["069147755dba2601"]]},{"id":"9dc16ae92629d591","type":"api-current-state","z":"0306219034b546af","name":"Flux Enabled?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"true","halt_if_type":"bool","halt_if_compare":"is","entity_id":"{{id_flux}}","state_type":"habool","blockInputOverrides":true,"outputProperties":[],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":900,"y":300,"wires":[["7892b1ed76415d9f"],[]]},{"id":"73e913c89de5c351","type":"change","z":"0306219034b546af","name":"Set id_flux","rules":[{"t":"set","p":"id_flux","pt":"msg","to":"payload.entity_id","tot":"msg"},{"t":"change","p":"id_flux","pt":"msg","from":"^light.","fromt":"re","to":"input_boolean.flux_","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":710,"y":300,"wires":[["9dc16ae92629d591"]]},{"id":"e7b8307569fb7786","type":"server-state-changed","z":"0306219034b546af","name":"Enabled","server":"c879ac61.99cd1","version":4,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.flux_","entityidfiltertype":"substring","outputinitially":false,"state_type":"habool","haltifstate":"true","halt_if_type":"bool","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"0","forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"},{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"x":80,"y":380,"wires":[["d30da4ba93adeee1"],[]]},{"id":"8241f1dac352e352","type":"switch","z":"0306219034b546af","name":"Brightness/CT Changed","property":"data.event","propertyType":"msg","rules":[{"t":"jsonata_exp","v":"data.event.old_state.attributes.brightness != data.event.new_state.attributes.brightness","vt":"jsonata"},{"t":"jsonata_exp","v":"data.event.old_state.attributes.color_temp != data.event.new_state.attributes.color_temp","vt":"jsonata"}],"checkall":"false","repair":false,"outputs":2,"x":290,"y":560,"wires":[["9e37488e1de21c71"],["9e37488e1de21c71"]],"inputLabels":["entity_id"],"outputLabels":["Brightness","Temperature"],"info":"Brightness\r\nColor Temp"},{"id":"402d945889a01598","type":"ha-sensor","z":"0306219034b546af","name":"Flux Period","entityConfig":"3bfbf7eb382d911a","version":0,"state":"payload.times_of_day.active.name","stateType":"msg","attributes":[{"property":"start","value":"payload.times_of_day.active.start","valueType":"msg"},{"property":"end","value":"payload.times_of_day.active.end","valueType":"msg"},{"property":"perc","value":"payload.times_of_day.active.perc","valueType":"msg"}],"inputOverride":"allow","outputProperties":[],"x":410,"y":480,"wires":[[]]},{"id":"835a1cd88f04abe1","type":"ha-sensor","z":"0306219034b546af","name":"Flux Brightness %","entityConfig":"bc3b5255c8b3353f","version":0,"state":"data.brightness_pct","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":430,"y":240,"wires":[[]]},{"id":"e34b7da5df06e19d","type":"ha-sensor","z":"0306219034b546af","name":"Flux Kelvin","entityConfig":"9f84f0ceba488ae7","version":0,"state":"data.kelvin","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":410,"y":420,"wires":[[]]},{"id":"d30da4ba93adeee1","type":"subflow:1f49a77.c544559","z":"0306219034b546af","name":"","x":240,"y":300,"wires":[["b9c31155c6cf7608","835a1cd88f04abe1","e34b7da5df06e19d","b87abab4cb360b91","d61614e6162f2744"],["402d945889a01598"]]},{"id":"9e37488e1de21c71","type":"subflow:cf82d4d1d0e8c57e","z":"0306219034b546af","name":"Who","env":[],"x":490,"y":560,"wires":[["3f13a3f733c58374"]]},{"id":"3f13a3f733c58374","type":"switch","z":"0306219034b546af","name":"User","property":"data.context.user_system","propertyType":"msg","rules":[{"t":"false"},{"t":"null"},{"t":"else"}],"checkall":"false","repair":false,"outputs":3,"x":610,"y":560,"wires":[["069147755dba2601"],["069147755dba2601"],[]]},{"id":"b87abab4cb360b91","type":"ha-sensor","z":"0306219034b546af","name":"Flux Color Temp","entityConfig":"cf4cf5f432945232","version":0,"state":"data.color_temp","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":420,"y":360,"wires":[[]]},{"id":"d61614e6162f2744","type":"ha-sensor","z":"0306219034b546af","name":"Flux Brightness","entityConfig":"e5cc7dc7c35938e4","version":0,"state":"data.brightness","stateType":"msg","attributes":[],"inputOverride":"allow","outputProperties":[],"x":420,"y":180,"wires":[[]]},{"id":"7892b1ed76415d9f","type":"api-call-service","z":"0306219034b546af","name":"Light","server":"c879ac61.99cd1","version":5,"debugenabled":false,"domain":"light","service":"turn_on","areaId":[],"deviceId":[],"entityId":["{{payload.entity_id}}"],"data":"{\t \"brightness\": data.brightness,\t \"color_temp\": data.color_temp,\t \"transition\": payload.timeSinceChangedMs>30000?15:1\t}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1070,"y":300,"wires":[[]]},{"id":"c879ac61.99cd1","type":"server","name":"Home Assistant","version":5,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30","areaSelector":"friendlyName","deviceSelector":"friendlyName","entitySelector":"friendlyName","statusSeparator":"at: ","statusYear":"hidden","statusMonth":"short","statusDay":"numeric","statusHourCycle":"h23","statusTimeFormat":"h:m","enableGlobalContextStore":true},{"id":"3bfbf7eb382d911a","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"cdf085f2f5c65493","name":"Flux Period","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Flux Period"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"bc3b5255c8b3353f","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"a61349185d4aea15","name":"Flux Brightness %","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Flux Brightness %"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"9f84f0ceba488ae7","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"7e46b77ac466d856","name":"Flux Temperature","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Flux Temperature"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"cf4cf5f432945232","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"a314718335efe62a","name":"Flux Color Temp","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Flux Color Temp"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"e5cc7dc7c35938e4","type":"ha-entity-config","server":"c879ac61.99cd1","deviceConfig":"6919bd09f0556e1f","name":"Flux Brightness","version":"6","entityType":"sensor","haConfig":[{"property":"name","value":"Flux Brightness"},{"property":"icon","value":""},{"property":"entity_category","value":""},{"property":"entity_picture","value":""},{"property":"device_class","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""}],"resend":false,"debugEnabled":false},{"id":"cdf085f2f5c65493","type":"ha-device-config","name":"Flux Period","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"a61349185d4aea15","type":"ha-device-config","name":"Flux Brightness %","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"7e46b77ac466d856","type":"ha-device-config","name":"Flux Temperature","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"a314718335efe62a","type":"ha-device-config","name":"Flux Color Temp","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""},{"id":"6919bd09f0556e1f","type":"ha-device-config","name":"Flux Brightness","hwVersion":"","manufacturer":"Node-RED","model":"","swVersion":""}]
@pacjo There is nothing personal in the Home Assistant
server node and Home location
contains only your latitude & longitude.
As for my post above with new coding, it wasn’t working as desired and I’m still tweaking it…
@dbrunt im trying to use your code based on tef2one but im having some issues… i see that u are still tweaking it but maybe u had this problem aswell?
When im turning on lights, other lights are also changing color and brightness when they are not supposed to change. the change is also completely random and i cant find why using the debug nodes.
im pretty newish to node-red so im sorry if i sound stupid
No, I did not have that problem and no, noobs are not stupid, they just don’t know all the ins and outs yet.
I still remember when I was I was new to NR…more or less a year or so ago! Debug is your best friend, along with a logical brain! I almost always change Debug to complete msg object as just seeing payload it often is not enough. More info is almost always better!
I have sidelined this routine for now as I am re-testing the HA integration Adaptive Lighting. I abandoned it maybe 18 months ago when I discovered the circadian function using spline curve in NR. So my Node-Red Circadian is currently inactive while I test out Adaptive Lighting since it has matured a lot since then…
Anything I can do to assist, happy to help!
I get an error trying to import your subflow. I think it might be due to a Node-RED update. Would you mind resharing it?