Here is my new revised logic which now implements manual take-over of the brightness &/or color temp until light is switched off/on or circadian booleans are toggled:
[{"id":"03454e69d1fb38da","type":"subflow","name":"Color / Brightness","info":"Color / Brightness Control commands for q-gate node","category":"","in":[{"x":340,"y":120,"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 circadian_mireds = global.get(\"nr_circadian_mireds\");\nvar circadian_brightness = global.get(\"nr_circadian_brightness\");\nvar calculated_brightness_state = Math.round(circadian_brightness * 0.996078431);\nif (calculated_brightness_state == 254) {calculated_brightness_state = 255}\nvar entity_id = msg.data.entity_id\n/*\nvar current_brightness = global.get('homeassistant.homeAssistant.states[\"' + entity_id + '\"].attributes.brightness.state');\nvar current_color_temp = global.get('homeassistant.homeAssistant.states[\"' + entity_id + '\"].attributes.color_temp.state');\n*/\nvar current_brightness = msg.data.new_state.attributes.brightness;\nvar current_color_temp = msg.data.new_state.attributes.color_temp;\n\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 \"Calculated state brightness\": calculated_brightness_state,\n \"Circadian brightness\": circadian_brightness\n }\n\nif (msg.data.old_state.state == \"on\" && msg.data.new_state.state == \"on\"){\n\n if (msg.data.new_state.attributes.color_temp == circadian_mireds &&\n current_brightness == calculated_brightness_state){\n return [{topic: \"control\", payload: \"open\"}, {topic: \"control\", payload: \"open\"}, debug]\n }\n if (msg.data.new_state.attributes.color_temp != circadian_mireds &&\n current_brightness == calculated_brightness_state){\n return [{topic: \"control\", payload: \"close\"}, {topic: \"control\", payload: \"open\"}, debug]\n }\n if (msg.data.new_state.attributes.color_temp == circadian_mireds &&\n current_brightness != calculated_brightness_state){\n return [{topic: \"control\", payload: \"open\"}, {topic: \"control\", payload: \"close\"}, debug]\n }\n if (msg.data.new_state.attributes.color_temp != circadian_mireds && \n current_brightness != calculated_brightness_state){\n return [{topic: \"control\", payload: \"close\"}, {topic: \"control\", payload: \"close\"}, debug]\n }\n }\n \nif (msg.data.old_state.state == \"off\" && msg.data.new_state.state == \"on\"){\n return [ { topic: \"control\", payload: \"open\" }, { topic: \"control\", payload: \"open\" }, debug ]\n }\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":120,"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":480,"y":180,"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":480,"y":220,"wires":[]},{"id":"e812678d.651e28","type":"subflow","name":"Circadian Calculator","info":"","category":"","in":[{"x":40,"y":240,"wires":[{"id":"aa4b86d8.b17118"}]}],"out":[{"x":1130,"y":120,"wires":[{"id":"40de744.1e2ca8c","port":0}]},{"x":1130,"y":180,"wires":[{"id":"15b473ec45fa7fc4","port":0}]},{"x":1170,"y":280,"wires":[{"id":"6f365d7d05905955","port":0}]},{"x":1170,"y":340,"wires":[{"id":"c26bdcca.eb483","port":0}]}],"env":[],"meta":{},"color":"#DDAA99","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":470,"y":240,"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":710,"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":720,"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":720,"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":720,"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":710,"y":280,"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":720,"y":320,"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":720,"y":400,"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":720,"y":360,"wires":[["c26bdcca.eb483","6f365d7d05905955"]]},{"id":"a330b219.92e4e","type":"function","z":"e812678d.651e28","name":"Times of Day","func":"var newmsg = JSON.parse(JSON.stringify(msg));\nnewmsg.payload.times_of_day = {};\n\nprocessTimeOfDay = 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":310,"y":240,"wires":[["5de89261.4fb97c"]]},{"id":"40de744.1e2ca8c","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"254","action":"clamp","round":true,"property":"payload","name":"","x":940,"y":120,"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":950,"y":340,"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":150,"y":240,"wires":[["a330b219.92e4e"]]},{"id":"15b473ec45fa7fc4","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"100","action":"clamp","round":true,"property":"payload","name":"","x":940,"y":180,"wires":[[]]},{"id":"6f365d7d05905955","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"370.37","maxout":"153.85","action":"clamp","round":true,"property":"payload","name":"","x":960,"y":280,"wires":[[]]},{"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":"f5e1d08b.a8cd58","type":"ha-entity","z":"7ea0620.a243ca","name":"kelvin","server":"c879ac61.99cd1","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"nr_circadian_kelvin"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:brightness-6"},{"property":"unit_of_measurement","value":"K"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":890,"y":260,"wires":[[]]},{"id":"365094a5.72bb5c","type":"subflow:e812678d.651e28","z":"7ea0620.a243ca","name":"","env":[],"x":480,"y":170,"wires":[["5f4a2fbe.d6b89"],["2bd57efd76cfcedf"],["eb1275669172038f"],["947dde334221e6b9"]]},{"id":"e80bd956.f2e098","type":"ha-entity","z":"7ea0620.a243ca","name":"color_temp","server":"c879ac61.99cd1","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"nr_circadian_color_temp"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:brightness-6"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":914,"y":200,"wires":[["53a933a438c1326b"]]},{"id":"476cda43.0f4c94","type":"ha-entity","z":"7ea0620.a243ca","name":"brightness","server":"c879ac61.99cd1","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"nr_circadian_brightness"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:brightness-auto"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":false,"outputLocation":"","outputLocationType":"none","inputOverride":"block","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":914,"y":82,"wires":[["ba7018086eca537b"]]},{"id":"a7bca137.c0d2f","type":"comment","z":"7ea0620.a243ca","name":"Update","info":"","x":70,"y":40,"wires":[]},{"id":"60a4dca9.c29d14","type":"api-call-service","z":"7ea0620.a243ca","name":"Light 1","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.office_light_1","data":"{\t \"brightness\": msg.payload.brightness,\t \"color_temp\": msg.payload.color_temp\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1250,"y":480,"wires":[[]]},{"id":"5f4a2fbe.d6b89","type":"function","z":"7ea0620.a243ca","name":"global brightness","func":"/*\nvar new_brightness = msg.payload;\nif (new_brightness == 254) {new_brightness=255;}\n*/\nvar new_brightness = (msg.payload == 254) ? 255 : msg.payload;\nvar old_brightness = global.get('nr_circadian_brightness');\nif (old_brightness == new_brightness) {return null}\nglobal.set('nr_circadian_brightness',new_brightness);\n/* \nmsg.payload = new_brightness;\nreturn msg\n*/\nreturn {payload: new_brightness}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":82,"wires":[["476cda43.0f4c94"]]},{"id":"30bf6ebc.f4da52","type":"function","z":"7ea0620.a243ca","name":"global kelvin","func":"/*var new_kelvin = msg.payload;*/\nvar new_kelvin = Math.round(1000000/msg.payload,0);\nvar old_kelvin = global.get('nr_circadian_kelvin');\nif (new_kelvin == old_kelvin) return null;\nglobal.set('nr_circadian_kelvin',new_kelvin);\nreturn {payload: new_kelvin}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":300,"wires":[[]]},{"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":176,"wires":[["365094a5.72bb5c"],[]]},{"id":"934e0600896a7adb","type":"link out","z":"7ea0620.a243ca","name":"Kelvin","mode":"link","links":["4b80d3dcd0dcb9fa","4593a42aa239dadd","2a3d1ccf39330b28","f6f58ab7e35f5688","eb0c9865a1d29657"],"x":1209,"y":200,"wires":[]},{"id":"b1ee887a5f59e581","type":"link out","z":"7ea0620.a243ca","name":"Brightness","mode":"link","links":["bb5ea6235f3f465f","e376d76995dda48c","bfc5edc53296a8c4","4193dc61304afe65","4f8d44ef76bac586","fe41bfcf0ed50cf5","f469dccbd0fea627","4c8de271d9d32579","17fcb852b5d4df73"],"x":1209,"y":82,"wires":[]},{"id":"9dfb80638a8e3d73","type":"q-gate","z":"7ea0620.a243ca","name":"color_temp 1","controlTopic":"control","defaultState":"closed","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":830,"y":460,"wires":[["ee6e3c5a8750dbd3"]]},{"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":830,"y":520,"wires":[["ee6e3c5a8750dbd3"]]},{"id":"448f5e6c691dccc4","type":"server-state-changed","z":"7ea0620.a243ca","name":"Light 1","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.office_light_1","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"milliseconds","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":370,"y":500,"wires":[["9843d42f60a63e30"]]},{"id":"5cd0d7153aaad741","type":"ha-entity","z":"7ea0620.a243ca","name":"brightness_pct","server":"c879ac61.99cd1","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"nr_circadian_brightness_pct"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:brightness-percent"},{"property":"unit_of_measurement","value":"%"},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"msg","inputOverride":"block","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":924,"y":140,"wires":[[]]},{"id":"2a3d1ccf39330b28","type":"link in","z":"7ea0620.a243ca","name":"Office Light 1 Color","links":["934e0600896a7adb","a8f21399bc702421","cd1e6d98e1856bda","5dfe7cf2b9de1bed"],"x":685,"y":458,"wires":[["9dfb80638a8e3d73","11dfa753a1a2cd05"]]},{"id":"4f8d44ef76bac586","type":"link in","z":"7ea0620.a243ca","name":"Office Light 1 Brightness","links":["a8f21399bc702421","b1ee887a5f59e581","f66d24bc98a1e3de","5dfe7cf2b9de1bed"],"x":685,"y":543,"wires":[["1c0b19f6eaee2844","94a02ed09a89725d"]]},{"id":"f75a6792daaeb0b4","type":"comment","z":"7ea0620.a243ca","name":"Office","info":"","x":70,"y":380,"wires":[]},{"id":"eb1275669172038f","type":"function","z":"7ea0620.a243ca","name":"global mireds","func":"var new_mireds = msg.payload\nvar old_mireds = global.get('nr_circadian_mireds')\nif (new_mireds == old_mireds) return null;\nglobal.set('nr_circadian_mireds',new_mireds);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":200,"wires":[["e80bd956.f2e098"]]},{"id":"2bd57efd76cfcedf","type":"function","z":"7ea0620.a243ca","name":"global brightness %","func":"var new_brightness_pct = msg.payload;\nvar old_brightness_pct = global.get('nr_circadian_brightness_pct');\nif (new_brightness_pct == old_brightness_pct) return null;\nglobal.set('nr_circadian_brightness_pct',new_brightness_pct);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":730,"y":140,"wires":[["5cd0d7153aaad741"]]},{"id":"11dfa753a1a2cd05","type":"ha-entity","z":"7ea0620.a243ca","name":"Light 1","server":"c879ac61.99cd1","version":2,"debugenabled":false,"outputs":1,"entityType":"binary_sensor","config":[{"property":"name","value":"Office Light 1 Color Control"},{"property":"device_class","value":"running"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":810,"y":400,"wires":[[]]},{"id":"94a02ed09a89725d","type":"ha-entity","z":"7ea0620.a243ca","name":"Light 1","server":"c879ac61.99cd1","version":2,"debugenabled":false,"outputs":1,"entityType":"binary_sensor","config":[{"property":"name","value":"Office Light 1 Brightness Control"},{"property":"device_class","value":"running"},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload = \"open\" ? \"on\" : \"off\"\t","stateType":"jsonata","attributes":[{"property":"command","value":"payload","valueType":"msg"}],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":810,"y":579,"wires":[[]]},{"id":"ee6e3c5a8750dbd3","type":"join","z":"7ea0620.a243ca","name":"","mode":"custom","build":"merged","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"2","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":990,"y":480,"wires":[["c6387631e23d9171"]]},{"id":"53a933a438c1326b","type":"change","z":"7ea0620.a243ca","name":"change payload","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.color_temp","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1084,"y":200,"wires":[["934e0600896a7adb"]]},{"id":"ba7018086eca537b","type":"change","z":"7ea0620.a243ca","name":"change payload","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.brightness","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1084,"y":82,"wires":[["b1ee887a5f59e581"]]},{"id":"f6a0b62593cc81c1","type":"interval-multiples-timer","z":"7ea0620.a243ca","interval":"60000","payload":"","topic":"","name":"Every minute","x":86,"y":160,"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":200,"wires":[["f7382c3f63fec06f"]]},{"id":"2758054b03a4112e","type":"subflow:03454e69d1fb38da","z":"7ea0620.a243ca","name":"Sub","x":650,"y":500,"wires":[["11dfa753a1a2cd05","9dfb80638a8e3d73"],["1c0b19f6eaee2844","94a02ed09a89725d"],[]]},{"id":"9843d42f60a63e30","type":"trigger","z":"7ea0620.a243ca","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"2","extend":true,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":520,"y":500,"wires":[["2758054b03a4112e"]]},{"id":"947dde334221e6b9","type":"function","z":"7ea0620.a243ca","name":"global kelvin","func":"var new_kelvin = msg.payload;\n/*var new_kelvin = Math.round(1000000/msg.payload,0);*/\nvar old_kelvin = global.get('nr_circadian_kelvin');\nif (new_kelvin == old_kelvin) return null;\nglobal.set('nr_circadian_kelvin',new_kelvin);\nreturn {payload: new_kelvin}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":710,"y":260,"wires":[["f5e1d08b.a8cd58"]]},{"id":"c6387631e23d9171","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":1120,"y":480,"wires":[["60a4dca9.c29d14"]]},{"id":"c879ac61.99cd1","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":false,"cacheJson":true,"heartbeat":false,"heartbeatInterval":"30"}]