You can use “Range” node to easily scale/shift values.
Once they are on they can be reduced to 1%-6% (there’s no difference in light level below 6%).
I had to change the initial timestamp injection into Sub Circadian NR to 10 seconds. The Gain and Warmth sometimes are not initialized for ~5 seconds…
re: polling
So you are saying this is not good?
When motion is detected the fireplace light turns on instantly.
How else do I do conditional logic based on states of entities?
How can queue-gate help?
On this image actions are triggered by events. it’s ok.
I commented on some previous image, where you were checking conditions every minute (there were inject node named this way)
I’m following everything you’ve done here, and it is working for me, EXCEPT the in/out actions…
What do they do, and how are you using them in the actual lighting flow??
The in/out actions are simply links into/out of the subroutine.
It’s how you specify the input(s) and output(s) of the subroutine.
If you never use the Times of Day output you could reduce the outputs to two and the subroutine module would then only have two outputs…
Daniel, would you mind posting your exported bathroom flow with the Circadian actionflow node? I’m trying to figure out how to implement that and a reference would be really helpful.
Sure, here you go…
[{"id":"e812678d.651e28","type":"subflow","name":"Circadian Calculator","info":"","category":"","in":[{"x":60,"y":160,"wires":[{"id":"aa4b86d8.b17118"}]}],"out":[{"x":1120,"y":140,"wires":[{"id":"40de744.1e2ca8c","port":0}]},{"x":1120,"y":340,"wires":[{"id":"c26bdcca.eb483","port":0}]},{"x":520,"y":400,"wires":[{"id":"a330b219.92e4e","port":0}]}],"env":[],"color":"#DDAA99"},{"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":510,"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":750,"y":80,"wires":[["40de744.1e2ca8c"]]},{"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":760,"y":120,"wires":[["40de744.1e2ca8c"]]},{"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":760,"y":200,"wires":[["40de744.1e2ca8c"]]},{"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":760,"y":160,"wires":[["40de744.1e2ca8c"]]},{"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":750,"y":280,"wires":[["c26bdcca.eb483"]]},{"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":760,"y":320,"wires":[["c26bdcca.eb483"]]},{"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":760,"y":400,"wires":[["c26bdcca.eb483"]]},{"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":760,"y":360,"wires":[["c26bdcca.eb483"]]},{"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":"","x":290,"y":240,"wires":[["5de89261.4fb97c"]]},{"id":"40de744.1e2ca8c","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"1","maxout":"100","action":"scale","round":true,"property":"payload","name":"","x":980,"y":140,"wires":[[]]},{"id":"c26bdcca.eb483","type":"range","z":"e812678d.651e28","minin":"0","maxin":"1","minout":"2000","maxout":"5500","action":"scale","round":true,"property":"payload","name":"","x":990,"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":190,"y":160,"wires":[["a330b219.92e4e"]]},{"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":"78328d42.dfbd24","type":"comment","z":"7ea0620.a243ca","name":"Circadian Routines","info":"","x":90,"y":20,"wires":[]},{"id":"a7bca137.c0d2f","type":"comment","z":"7ea0620.a243ca","name":"Update HA Entities","info":"","x":150,"y":60,"wires":[]},{"id":"bfbe267f.ea05f8","type":"inject","z":"7ea0620.a243ca","name":"Every 2 minutes","props":[{"p":"payload"}],"repeat":"120","crontab":"","once":true,"onceDelay":"10","topic":"","payloadType":"date","x":110,"y":124,"wires":[["365094a5.72bb5c"]]},{"id":"365094a5.72bb5c","type":"subflow:e812678d.651e28","z":"7ea0620.a243ca","name":"","env":[],"x":340,"y":124,"wires":[["5f4a2fbe.d6b89"],["4760702f.2d094","30bf6ebc.f4da52"],[]]},{"id":"5f4a2fbe.d6b89","type":"function","z":"7ea0620.a243ca","name":"global brightness","func":"var brightness = msg.payload\nglobal.set('nr_circadian_brightness',brightness)\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":651,"y":64,"wires":[["476cda43.0f4c94"]]},{"id":"4760702f.2d094","type":"function","z":"7ea0620.a243ca","name":"kelvin to mireds","func":"var kelvin = msg.payload;\nvar mireds = Math.round(1000000/kelvin);\n\nmsg.payload = mireds;\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":641,"y":124,"wires":[["e80bd956.f2e098"]]},{"id":"30bf6ebc.f4da52","type":"function","z":"7ea0620.a243ca","name":"global kelvin","func":"var kelvin = msg.payload;\nglobal.set('nr_circadian_kelvin',kelvin)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":631,"y":184,"wires":[["f5e1d08b.a8cd58"]]},{"id":"476cda43.0f4c94","type":"ha-entity","z":"7ea0620.a243ca","name":"HA brightness_pct","server":"c879ac61.99cd1","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"nr_circadian_brightness"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:brightness-percent"},{"property":"unit_of_measurement","value":"%"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":851,"y":64,"wires":[[]]},{"id":"e80bd956.f2e098","type":"ha-entity","z":"7ea0620.a243ca","name":"HA mireds","server":"c879ac61.99cd1","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"nr_circadian_mireds"},{"property":"device_class","value":""},{"property":"icon","value":"mdi:brightness-6"},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":831,"y":124,"wires":[[]]},{"id":"f5e1d08b.a8cd58","type":"ha-entity","z":"7ea0620.a243ca","name":"HA kelvin","server":"c879ac61.99cd1","version":1,"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"}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"msg","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"","outputPayloadType":"str","x":821,"y":184,"wires":[[]]},{"id":"c879ac61.99cd1","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
[{"id":"5031c141.26153","type":"server-state-changed","z":"7ea0620.a243ca","name":"Circadian Bedroom","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_bedroom","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","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":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":430,"y":746,"wires":[["9e4df569.ebe9a8","db924d5b.af865"],[]]},{"id":"d67b58d0.2688b8","type":"api-current-state","z":"7ea0620.a243ca","name":"Circadian Office?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.circadian_lighting_office","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":410,"y":414,"wires":[["6b608b09.49d6c4","c8f1a755.ca59b8","1abf244.caf4edc"],[]]},{"id":"6b608b09.49d6c4","type":"api-current-state","z":"7ea0620.a243ca","name":"Light 2?","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":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":660,"y":380,"wires":[["fd2624e20a6f7bdc"],[]]},{"id":"71e41def.76e254","type":"server-state-changed","z":"7ea0620.a243ca","name":"Cicadian Office","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_office","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","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":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":420,"y":354,"wires":[["6b608b09.49d6c4","c8f1a755.ca59b8","1abf244.caf4edc"],[]]},{"id":"e19a5b80.4cd298","type":"api-current-state","z":"7ea0620.a243ca","name":"Circadian Bedroom?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.circadian_lighting_bedroom","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":420,"y":686,"wires":[["9e4df569.ebe9a8","db924d5b.af865"],[]]},{"id":"9e4df569.ebe9a8","type":"api-current-state","z":"7ea0620.a243ca","name":"Lamp 1?","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":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":660,"y":680,"wires":[["1f25b966d1c6291c"],[]]},{"id":"db924d5b.af865","type":"api-current-state","z":"7ea0620.a243ca","name":"Lamp 2?","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":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":660,"y":740,"wires":[["c03d3dd29a831494"],[]]},{"id":"ea7ccfbc.1e722","type":"comment","z":"7ea0620.a243ca","name":"Adaptive Lighting","info":"","x":80,"y":260,"wires":[]},{"id":"29602517.69553a","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":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":280,"y":554,"wires":[["d67b58d0.2688b8","e19a5b80.4cd298"],[]]},{"id":"b957873e.b725c8","type":"server-state-changed","z":"7ea0620.a243ca","name":"Circadian Bathroom","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_bathroom","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","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":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":330,"y":1020,"wires":[["a600f9d9.a4aaf8"],[]]},{"id":"727a0fc0.fb604","type":"api-current-state","z":"7ea0620.a243ca","name":"Circadian Bathroom?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.circadian_lighting_bathroom","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":320,"y":960,"wires":[["a600f9d9.a4aaf8"],[]]},{"id":"a600f9d9.a4aaf8","type":"api-current-state","z":"7ea0620.a243ca","name":"Bathroom lights?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.bathroom_light","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":570,"y":1013,"wires":[["db1e6b12.1c4c48"],[]]},{"id":"db1e6b12.1c4c48","type":"api-current-state","z":"7ea0620.a243ca","name":"Sleep Mode?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.sleep_mode","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":770,"y":1040,"wires":[["15f2057c.6e117b"],["f58d71ab4774bd94"]]},{"id":"c8f1a755.ca59b8","type":"api-current-state","z":"7ea0620.a243ca","name":"Light 1?","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":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":660,"y":260,"wires":[["60a4dca9.c29d14"],[]]},{"id":"1abf244.caf4edc","type":"api-current-state","z":"7ea0620.a243ca","name":"Light 3?","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":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":665,"y":492,"wires":[["3b52cbf7b1f2d48a"],[]]},{"id":"60a4dca9.c29d14","type":"api-call-service","z":"7ea0620.a243ca","name":"Adapt","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.office_light_1","data":"{\t \"brightness_pct\": $globalContext('nr_circadian_brightness'),\t \"kelvin\": $globalContext('nr_circadian_kelvin')\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":848,"y":280,"wires":[[]]},{"id":"4a79291e.6b3af8","type":"server-state-changed","z":"7ea0620.a243ca","name":"Sleep Mode","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.sleep_mode","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":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":350,"y":1080,"wires":[["a600f9d9.a4aaf8"]]},{"id":"15f2057c.6e117b","type":"api-call-service","z":"7ea0620.a243ca","name":"Reduce","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.bathroom_light","data":"{\"brightness_pct\":6}","dataType":"json","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":943,"y":1014,"wires":[[]]},{"id":"9753474b.7a5b48","type":"server-state-changed","z":"7ea0620.a243ca","name":"Lamp 1","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.bedroom_lamp_1","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","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":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":210,"y":660,"wires":[["e19a5b80.4cd298"],[]]},{"id":"af4a352d.17fdb8","type":"server-state-changed","z":"7ea0620.a243ca","name":"Lamp 2","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.bedroom_lamp_2","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","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":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":230,"y":720,"wires":[["e19a5b80.4cd298"],[]]},{"id":"6c8df53b.9f958c","type":"server-state-changed","z":"7ea0620.a243ca","name":"Bathroom light","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.bathroom_light","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":390,"y":1140,"wires":[["8d9a5899f0582036"],[]]},{"id":"3f5fe946.3243c6","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":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":301,"wires":[["d67b58d0.2688b8"],[]]},{"id":"31353af0.304b36","type":"server-state-changed","z":"7ea0620.a243ca","name":"Light 2","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.office_light_2","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":349,"wires":[["d67b58d0.2688b8"],[]]},{"id":"3304905.749ad7","type":"server-state-changed","z":"7ea0620.a243ca","name":"Light 3","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.office_light_3","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":170,"y":400,"wires":[["d67b58d0.2688b8"],[]]},{"id":"8d9a5899f0582036","type":"delay","z":"7ea0620.a243ca","name":"200ms","pauseType":"delay","timeout":"200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":610,"y":1075,"wires":[["db1e6b12.1c4c48"]]},{"id":"fd2624e20a6f7bdc","type":"delay","z":"7ea0620.a243ca","name":"200ms","pauseType":"delay","timeout":"200","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":810,"y":373,"wires":[["3863e49219f2c06c"]]},{"id":"3b52cbf7b1f2d48a","type":"delay","z":"7ea0620.a243ca","name":"400ms","pauseType":"delay","timeout":"400","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":810,"y":486,"wires":[["c5c6137c20db841c"]]},{"id":"3863e49219f2c06c","type":"api-call-service","z":"7ea0620.a243ca","name":"Adapt","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.office_light_2","data":"{\t \"brightness_pct\": $globalContext('nr_circadian_brightness'),\t \"kelvin\": $globalContext('nr_circadian_kelvin')\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":970,"y":434,"wires":[[]]},{"id":"c5c6137c20db841c","type":"api-call-service","z":"7ea0620.a243ca","name":"Adapt","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.office_light_3","data":"{\t \"brightness_pct\": $globalContext('nr_circadian_brightness'),\t \"kelvin\": $globalContext('nr_circadian_kelvin')\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":970,"y":554,"wires":[[]]},{"id":"1f25b966d1c6291c","type":"api-call-service","z":"7ea0620.a243ca","name":"Adapt","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.bedroom_lamp_1","data":"{\t \"brightness_pct\": $globalContext('nr_circadian_brightness'),\t \"kelvin\": $globalContext('nr_circadian_kelvin')\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":640,"wires":[[]]},{"id":"c03d3dd29a831494","type":"api-call-service","z":"7ea0620.a243ca","name":"Adapt","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.bedroom_lamp_2","data":"{\t \"brightness_pct\": $globalContext('nr_circadian_brightness'),\t \"kelvin\": $globalContext('nr_circadian_kelvin')\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":850,"y":760,"wires":[[]]},{"id":"af0947ae9b3c8831","type":"complete","z":"7ea0620.a243ca","name":"Brightness","scope":["5f4a2fbe.d6b89"],"uncaught":false,"x":65,"y":834,"wires":[["e24ebf433f4399fa"]]},{"id":"20f693da04d7cd55","type":"complete","z":"7ea0620.a243ca","name":"Kelvin","scope":["30bf6ebc.f4da52"],"uncaught":false,"x":70,"y":460,"wires":[["d409ec04a232cef6"]]},{"id":"d409ec04a232cef6","type":"rbe","z":"7ea0620.a243ca","name":"Min 10","func":"deadbandEq","gap":"10","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":190,"y":460,"wires":[["17b9615cb1f36278"]]},{"id":"e6905968d35e814c","type":"throttle","z":"7ea0620.a243ca","name":"","throttleType":"time","timeLimit":"30","timeLimitType":"seconds","countLimit":0,"blockSize":0,"locked":false,"x":130,"y":554,"wires":[["29602517.69553a"]]},{"id":"e24ebf433f4399fa","type":"rbe","z":"7ea0620.a243ca","name":"Min 5","func":"deadbandEq","gap":"5","start":"","inout":"out","septopics":false,"property":"payload","topi":"topic","x":95,"y":754,"wires":[["50d23382e730c21d","e86a8c7a93b939c3"]]},{"id":"f58d71ab4774bd94","type":"api-call-service","z":"7ea0620.a243ca","name":"Adapt","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.bathroom_light","data":"{\t \"brightness_pct\": $max(\t [\t 6,\t $globalContext('nr_circadian_brightness')\t ]\t )\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":930,"y":1080,"wires":[[]]},{"id":"50d23382e730c21d","type":"api-current-state","z":"7ea0620.a243ca","name":"Kitchen light?","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"light.kitchen_light","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","x":400,"y":880,"wires":[["edb74bee98fc49eb"],[]]},{"id":"edb74bee98fc49eb","type":"api-call-service","z":"7ea0620.a243ca","name":"Adapt","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.kitchen_light","data":"{\t \"brightness_pct\": $max(\t [\t 10,\t $globalContext('nr_circadian_brightness')\t ]\t )\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":590,"y":880,"wires":[[]]},{"id":"e86a8c7a93b939c3","type":"api-current-state","z":"7ea0620.a243ca","name":"Circadian Brightness","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.circadian_lighting_brightness_bedroom","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":120,"y":620,"wires":[["e6905968d35e814c"],[]]},{"id":"17b9615cb1f36278","type":"api-current-state","z":"7ea0620.a243ca","name":"Circadian Color","server":"c879ac61.99cd1","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"input_boolean.circadian_lighting_color_bedroom","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":220,"y":500,"wires":[["e6905968d35e814c"],[]]},{"id":"c879ac61.99cd1","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]
I get this same error message every time I deploy. I’ve changed the latitude and longitude and also tried creating another location in the sunposition node but nothing has worked. Were you able to figure it out?
Thanks a lot for this very useful work @maxym and @dbrunt. I’ve just finished to set this up and this is great.
I would like to split the night in 2 parts though in order to be able to have more control over the curve. I started adding a time switch after the curve switch and added a “late_evening_curve”, the problem is that the percentage is incorrect because it still calculates the “night percentage”.
I have no idea how to program in javascript, even less in NodeRed so I was wondering if any of you could point me in the right direction to add a new timeblock so that the percentage is tracked in the times of day function?
The Times of Day currently calculates:
processTimeOfDay('night', newmsg.payload, "astronomicalDusk", "astronomicalDawn");
processTimeOfDay('morning', newmsg.payload, "astronomicalDawn", "goldenHourDawnEnd");
processTimeOfDay('day', newmsg.payload, "goldenHourDawnEnd", "sunsetStart");
processTimeOfDay('evening', newmsg.payload, "sunsetStart", "astronomicalDusk");
and is based on times from these sun-position points:
msg.payload.times the sun times as object.
msg.payload.times.astronomicalDawn night ends (morning astronomical twilight starts)
msg.payload.times.amateurDawn amateur astronomical dawn (sun at 12° before sunrise)
msg.payload.times.nauticalDawn nautical dawn (morning nautical twilight starts)
msg.payload.times.blueHourDawnStart blue Hour start (time for special photography photos starts)
msg.payload.times.civilDawn dawn (morning nautical twilight ends, morning civil twilight starts)
msg.payload.times.blueHourDawnEnd blue Hour end (time for special photography photos starts)
msg.payload.times.sunrise sunrise (top edge of the sun appears on the horizon)
msg.payload.times.sunriseEnd sunrise ends (bottom edge of the sun touches the horizon)
msg.payload.times.goldenHourDawnEnd morning golden hour (soft light, best time for photography) ends
msg.payload.times.solarNoon solar noon (sun is in the highest position)
msg.payload.times.goldenHourDuskStart evening golden hour starts
msg.payload.times.sunsetStart sunset starts (bottom edge of the sun touches the horizon)
msg.payload.times.sunset sunset (sun disappears below the horizon, evening civil twilight starts)
msg.payload.times.blueHourDuskStart nautical dusk start (evening astronomical twilight starts)
msg.payload.times.civilDusk dusk (evening nautical twilight starts)
msg.payload.times.blueHourDuskEnd nautical dusk end (evening astronomical twilight starts)
msg.payload.times.amateurDusk amateur astronomical dusk (sun at 12° after sunrise)
msg.payload.times.astronomicalDusk night starts (dark enough for astronomical observations)
msg.payload.times.nadir nadir (darkest moment of the night, sun is in the lowest position)
Are you trying to use something other than the above?
What have you got so far??
Thanks for trying to help but I was so frustrated I learned some Javascript and did it myself, although its probably FAR from being the most efficient way to code it.
Here is what I did for reference : I added a new timeblock between 22:00 (the time I usually go to bed) and the end of “night”. Then I added a fifth option in the curve switch that I called “late_evening”. The time could be customized by editing setHours(22) and set Minutes(00) to whatever time you want.
Here is the Times of Day JS code for reference :
var newmsg = JSON.parse(JSON.stringify(msg));
newmsg.payload.times_of_day = {};
processTimeOfDay = function(nme, obj, name_start, name_end) {
var ret = {};
ret.name = nme;
if (name_start == "sleepTime")
{
sleepDate = new Date(obj.times["sunsetStart"].ts)
sleepDate.setHours(22)
ret.start = sleepDate.setMinutes(0)
}
else
{
ret.start = obj.times[name_start].ts;
}
if (name_end == "sleepTime")
{
sleepDate = new Date(obj.times["sunsetStart"].ts)
sleepDate.setHours(22)
ret.end = sleepDate.setMinutes(0)
}
else
{
ret.end = obj.times[name_end].ts;
}
ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);
// to cover range starting before midnight and ending after it.
if (ret.start > ret.end)
{
var a;
// before midnight
if (ret.start < obj.ts)
{
a = new Date(ret.end);
a.setUTCDate(a.getUTCDate() + 1);
ret.end = a.getTime();
}
else if (ret.end > obj.ts)
{
a = new Date(ret.start);
a.setUTCDate(a.getUTCDate() - 1);
ret.start = a.getTime();
}
}
ret.perc = (obj.ts - ret.start) / (ret.end - ret.start);
obj.times_of_day[nme] = ret;
if (ret.start <= obj.ts && obj.ts < ret.end ) obj.times_of_day.active = ret;
}
processTimeOfDay('night', newmsg.payload, "sleepTime", "astronomicalDawn");
processTimeOfDay('morning', newmsg.payload, "astronomicalDawn", "goldenHourDawnEnd");
processTimeOfDay('day', newmsg.payload, "goldenHourDawnEnd", "sunsetStart");
processTimeOfDay('evening', newmsg.payload, "sunsetStart", "astronomicalDusk");
processTimeOfDay('late_evening', newmsg.payload, "astronomicalDusk", "sleepTime");
return newmsg;
Still looking to improve the curves for winter time.
Currently sunrise is at 8:40 local and at 9:40 brightness is still not capped (83% currently).
Am I crazy for wanting to introduce a maximum time for brightness being maxed out? In my opinion it should be capped at 9:00 am at the latest if not 8:30.
Maybe the curves could stay that way for the weekend but when I wake up at 6:40 to go to work it is really not practical.
I disagree that I am polling light states. I believe that the entity state check functions the same as entity state input. There is another node called poll state
which does poll HA but I am not using that:
Polls for the state at regular intervals, optionally also outputting at the start and when the state changes. Useful for either alert for non-communicating devices (time since change > 1 day for example) or dashboard graphs with consistent interval charts
Nevertheless I took your recommendation and converted most of my adaptive routines to use q-gate…
[{"id":"71e41def.76e254","type":"server-state-changed","z":"7ea0620.a243ca","name":"Cicadian Office","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_office","entityidfiltertype":"exact","outputinitially":true,"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":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":160,"y":640,"wires":[["96b088404703a698","a8f21399bc702421","4d272b41803cd1e0"]]},{"id":"60a4dca9.c29d14","type":"api-call-service","z":"7ea0620.a243ca","name":"Office 1","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.office_light_1","data":"{\t \"brightness_pct\": $globalContext('nr_circadian_brightness'),\t \"kelvin\": $globalContext('nr_circadian_kelvin')\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1340,"y":438,"wires":[[]]},{"id":"9753474b.7a5b48","type":"server-state-changed","z":"7ea0620.a243ca","name":"Lamp 1","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.bedroom_lamp_1","entityidfiltertype":"exact","outputinitially":true,"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":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":150,"y":786,"wires":[["de1be3f3be4af558"]]},{"id":"af4a352d.17fdb8","type":"server-state-changed","z":"7ea0620.a243ca","name":"Lamp 2","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.bedroom_lamp_2","entityidfiltertype":"exact","outputinitially":true,"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":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":150,"y":946,"wires":[["0018075bcf5c9c49"]]},{"id":"3f5fe946.3243c6","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":true,"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":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":70,"y":520,"wires":[["5f2a85ee0a9eddd8"]]},{"id":"31353af0.304b36","type":"server-state-changed","z":"7ea0620.a243ca","name":"Light 2","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.office_light_2","entityidfiltertype":"exact","outputinitially":true,"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":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":70,"y":580,"wires":[["fc514421545cef8b"]]},{"id":"3304905.749ad7","type":"server-state-changed","z":"7ea0620.a243ca","name":"Light 3","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.office_light_3","entityidfiltertype":"exact","outputinitially":true,"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":"minutes","ignorePrevStateNull":true,"ignorePrevStateUnknown":true,"ignorePrevStateUnavailable":true,"ignoreCurrentStateUnknown":true,"ignoreCurrentStateUnavailable":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":70,"y":700,"wires":[["9fcc97cbcd57c012"]]},{"id":"3863e49219f2c06c","type":"api-call-service","z":"7ea0620.a243ca","name":"Office 2","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.office_light_2","data":"{\t \"brightness_pct\": $globalContext('nr_circadian_brightness'),\t \"kelvin\": $globalContext('nr_circadian_kelvin')\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1340,"y":558,"wires":[[]]},{"id":"c5c6137c20db841c","type":"api-call-service","z":"7ea0620.a243ca","name":"Office 3","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.office_light_3","data":"{\t \"brightness_pct\": $globalContext('nr_circadian_brightness'),\t \"kelvin\": $globalContext('nr_circadian_kelvin')\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1340,"y":678,"wires":[[]]},{"id":"1f25b966d1c6291c","type":"api-call-service","z":"7ea0620.a243ca","name":"Lamp 1","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.bedroom_lamp_1","data":"{\t \"brightness_pct\": $globalContext('nr_circadian_brightness'),\t \"kelvin\": $globalContext('nr_circadian_kelvin')\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1340,"y":800,"wires":[[]]},{"id":"c03d3dd29a831494","type":"api-call-service","z":"7ea0620.a243ca","name":"Lamp 2","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.bedroom_lamp_2","data":"{\t \"brightness_pct\": $globalContext('nr_circadian_brightness'),\t \"kelvin\": $globalContext('nr_circadian_kelvin')\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1340,"y":920,"wires":[[]]},{"id":"af0947ae9b3c8831","type":"complete","z":"7ea0620.a243ca","name":"Brightness","scope":["5f4a2fbe.d6b89"],"uncaught":false,"x":560,"y":720,"wires":[[]]},{"id":"20f693da04d7cd55","type":"complete","z":"7ea0620.a243ca","name":"Kelvin","scope":["30bf6ebc.f4da52"],"uncaught":false,"x":570,"y":680,"wires":[[]]},{"id":"edb74bee98fc49eb","type":"api-call-service","z":"7ea0620.a243ca","name":"Kitchen","server":"c879ac61.99cd1","version":3,"debugenabled":false,"service_domain":"light","service":"turn_on","entityId":"light.kitchen_light","data":"{\t \"brightness_pct\": $max(\t [\t 10,\t $globalContext('nr_circadian_brightness')\t ]\t )\t}","dataType":"jsonata","mergecontext":"lightOptions","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1340,"y":1040,"wires":[[]]},{"id":"5953dc0a6a10c314","type":"server-state-changed","z":"7ea0620.a243ca","name":"Office Color","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_color_office","entityidfiltertype":"exact","outputinitially":true,"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":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":630,"y":540,"wires":[["ee744e044a31a35d","0571b237f436b3da","a0521c647d7368e9"]]},{"id":"3728361be31f9153","type":"server-state-changed","z":"7ea0620.a243ca","name":"Office Brightness","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.circadian_lighting_brightness_office","entityidfiltertype":"exact","outputinitially":true,"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":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":620,"y":600,"wires":[["8d896ca11111e0be","20e2fc251e2c9803","3d0ef8043052f45f"]]},{"id":"5fcdbdfcad60b453","type":"q-gate","z":"7ea0620.a243ca","name":"Kelvin","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":false,"x":1170,"y":534,"wires":[["3863e49219f2c06c"]]},{"id":"0571b237f436b3da","type":"multiSensor","z":"7ea0620.a243ca","name":"Color","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":910,"y":540,"wires":[["5fcdbdfcad60b453"],[]]},{"id":"96b088404703a698","type":"link out","z":"7ea0620.a243ca","name":"Control Light 1","mode":"link","links":["75d9a1fa54acf3a7"],"x":335,"y":520,"wires":[]},{"id":"75d9a1fa54acf3a7","type":"link in","z":"7ea0620.a243ca","name":"Control Light ","links":["96b088404703a698"],"x":795,"y":449,"wires":[["ee744e044a31a35d","8d896ca11111e0be"]]},{"id":"4b80d3dcd0dcb9fa","type":"link in","z":"7ea0620.a243ca","name":"Kelvin","links":["934e0600896a7adb"],"x":995,"y":360,"wires":[["9dfb80638a8e3d73","5fcdbdfcad60b453","f38eeefba2af67ce","e707970223078820","aa436d4aef53ba79"]]},{"id":"8d896ca11111e0be","type":"multiSensor","z":"7ea0620.a243ca","name":"Brightness","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":930,"y":480,"wires":[["1c0b19f6eaee2844"],[]]},{"id":"20e2fc251e2c9803","type":"multiSensor","z":"7ea0620.a243ca","name":"Brightness","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":930,"y":600,"wires":[["5731df33e0ef2e56"],[]]},{"id":"5f2a85ee0a9eddd8","type":"delay","z":"7ea0620.a243ca","name":"1s","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":190,"y":520,"wires":[["96b088404703a698"]]},{"id":"bb5ea6235f3f465f","type":"link in","z":"7ea0620.a243ca","name":"Brightness","links":["b1ee887a5f59e581"],"x":995,"y":1120,"wires":[["22570f7cadf11491","5731df33e0ef2e56","1c0b19f6eaee2844","0e8b24ed04b4935a","500b7e47055ea28c","fc77eb6f5d536827"]]},{"id":"5731df33e0ef2e56","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":false,"x":1150,"y":588,"wires":[["3863e49219f2c06c"]]},{"id":"f38eeefba2af67ce","type":"q-gate","z":"7ea0620.a243ca","name":"Kelvin","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":false,"x":1170,"y":654,"wires":[["c5c6137c20db841c"]]},{"id":"9dfb80638a8e3d73","type":"q-gate","z":"7ea0620.a243ca","name":"Kelvin","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":false,"x":1170,"y":414,"wires":[["60a4dca9.c29d14"]]},{"id":"22570f7cadf11491","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":false,"x":1150,"y":708,"wires":[["c5c6137c20db841c"]]},{"id":"1c0b19f6eaee2844","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":false,"x":1150,"y":468,"wires":[["60a4dca9.c29d14"]]},{"id":"ee744e044a31a35d","type":"multiSensor","z":"7ea0620.a243ca","name":"Color","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":910,"y":420,"wires":[["9dfb80638a8e3d73"],[]]},{"id":"a0521c647d7368e9","type":"multiSensor","z":"7ea0620.a243ca","name":"Color","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":910,"y":660,"wires":[["f38eeefba2af67ce"],[]]},{"id":"3d0ef8043052f45f","type":"multiSensor","z":"7ea0620.a243ca","name":"Brightness","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":930,"y":720,"wires":[["22570f7cadf11491"],[]]},{"id":"a8f21399bc702421","type":"link out","z":"7ea0620.a243ca","name":"Control Light 2","mode":"link","links":["3e80b096e94515cc"],"x":335,"y":604,"wires":[]},{"id":"3e80b096e94515cc","type":"link in","z":"7ea0620.a243ca","name":"Control Light 2","links":["a8f21399bc702421"],"x":795,"y":569,"wires":[["0571b237f436b3da","20e2fc251e2c9803"]]},{"id":"4d272b41803cd1e0","type":"link out","z":"7ea0620.a243ca","name":"Control Light 3","mode":"link","links":["def49da1aead571e"],"x":335,"y":700,"wires":[]},{"id":"def49da1aead571e","type":"link in","z":"7ea0620.a243ca","name":"Control Light 3","links":["4d272b41803cd1e0"],"x":795,"y":687,"wires":[["a0521c647d7368e9","3d0ef8043052f45f"]]},{"id":"e707970223078820","type":"q-gate","z":"7ea0620.a243ca","name":"Kelvin","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":false,"x":1170,"y":774,"wires":[["1f25b966d1c6291c"]]},{"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":false,"x":1150,"y":834,"wires":[["1f25b966d1c6291c"]]},{"id":"aa436d4aef53ba79","type":"q-gate","z":"7ea0620.a243ca","name":"Kelvin","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":false,"x":1170,"y":894,"wires":[["c03d3dd29a831494"]]},{"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":false,"x":1150,"y":954,"wires":[["c03d3dd29a831494"]]},{"id":"b492da7b0c54beed","type":"multiSensor","z":"7ea0620.a243ca","name":"Color","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":910,"y":780,"wires":[["e707970223078820"],[]]},{"id":"016c9e4808961ce6","type":"multiSensor","z":"7ea0620.a243ca","name":"Brightness","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":930,"y":840,"wires":[["0e8b24ed04b4935a"],[]]},{"id":"5c4dc9e961dadc7a","type":"multiSensor","z":"7ea0620.a243ca","name":"Color","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":910,"y":900,"wires":[["aa436d4aef53ba79"],[]]},{"id":"b53bab1b72346052","type":"multiSensor","z":"7ea0620.a243ca","name":"Brightness","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":930,"y":960,"wires":[["500b7e47055ea28c"],[]]},{"id":"9368eeec1b7c880b","type":"server-state-changed","z":"7ea0620.a243ca","name":"Bedroom Color","server":"c879ac61.99cd1","version":3,"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":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":620,"y":830,"wires":[["b492da7b0c54beed","5c4dc9e961dadc7a"]]},{"id":"7d8a0deef287ad2c","type":"server-state-changed","z":"7ea0620.a243ca","name":"Bedroom Brightness","server":"c879ac61.99cd1","version":3,"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":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":610,"y":890,"wires":[["016c9e4808961ce6","b53bab1b72346052"]]},{"id":"4ec21b16da174db6","type":"server-state-changed","z":"7ea0620.a243ca","name":"Cicadian Bedroom","server":"c879ac61.99cd1","version":3,"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":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":110,"y":866,"wires":[["de1be3f3be4af558","0018075bcf5c9c49"]]},{"id":"de1be3f3be4af558","type":"link out","z":"7ea0620.a243ca","name":"Control Lamp 1","mode":"link","links":["314d17f3aa61260f"],"x":275,"y":826,"wires":[]},{"id":"314d17f3aa61260f","type":"link in","z":"7ea0620.a243ca","name":"Control Lamp 1","links":["de1be3f3be4af558"],"x":795,"y":807,"wires":[["b492da7b0c54beed","016c9e4808961ce6"]]},{"id":"0018075bcf5c9c49","type":"link out","z":"7ea0620.a243ca","name":"Control Lamp 2","mode":"link","links":["c94d4bf1c6e8c1f5"],"x":275,"y":906,"wires":[]},{"id":"c94d4bf1c6e8c1f5","type":"link in","z":"7ea0620.a243ca","name":"Control Lamp 2","links":["0018075bcf5c9c49"],"x":795,"y":926,"wires":[["5c4dc9e961dadc7a","b53bab1b72346052"]]},{"id":"fc514421545cef8b","type":"delay","z":"7ea0620.a243ca","name":"1s","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":190,"y":580,"wires":[["a8f21399bc702421"]]},{"id":"9fcc97cbcd57c012","type":"delay","z":"7ea0620.a243ca","name":"1s","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":190,"y":700,"wires":[["4d272b41803cd1e0"]]},{"id":"39ef78c4c1d9700a","type":"multiSensor","z":"7ea0620.a243ca","name":"Brightness","idType":"msg","idField":"topic","inputType":"msg","inputValue":"payload","activeType":"str","activeValue":"off","inactiveType":"str","inactiveValue":"on","activateDelay":"0","activateDelayUnit":"seconds","inactivateDelay":"0","inactivateDelayUnit":"seconds","sendOnActiveType":"json","sendOnActive":"{\"payload\":\"queue\",\"data\":{},\"topic\":\"control\"}","sendOnInactiveType":"json","sendOnInactive":"{\"payload\":\"open\",\"data\":{},\"topic\":\"control\"}","sendOnTimeoutType":"pay","sendOnTimeout":"","aTimeout":"0","aTimeoutUnit":"minutes","sTimeout":"0","sTimeoutUnit":"minutes","seperated":false,"useCount":true,"outputs":2,"x":930,"y":1046,"wires":[["fc77eb6f5d536827"],[]]},{"id":"fc77eb6f5d536827","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":false,"x":1150,"y":1040,"wires":[["edb74bee98fc49eb"]]},{"id":"314c2c70ebd4f39a","type":"server-state-changed","z":"7ea0620.a243ca","name":"Kitchen","server":"c879ac61.99cd1","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"light.kitchen_light","entityidfiltertype":"exact","outputinitially":true,"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":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":650,"y":1046,"wires":[["39ef78c4c1d9700a"]]},{"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"}]
Range won’t work! The light needs 12% minimum to turn on but then I can reduce it to a minimum of 5%…
Am I crazy for wanting to introduce a maximum time for brightness being maxed out?
IMO, yes, at least in this logic! This circadian logic is to mimic actual outdoor sunlight for artificial lighting, not your own personal preferences for light levels and colors! Perhaps the HA add-on for circadian or adaptive lighting, or custom Node-Red/HA automations are better suited for your wishes, but you are free to have a go at trying to tweak this logic for your own desires…
if you need fixed value at particular time you probably has to split curves at that time. for example in your case at 9am.
The tricky part is to ensure that neighbor time points will never float over this point. for example if you use sunrise expecting it before 9.00, it must never appear after 9.00. if it happens you have to handle it properly in code and/or curves.
Thanks, I added some curves in order to have something I was happy with.
Here is my circadian function for reference :
[
{
"id": "e812678d.651e28",
"type": "subflow",
"name": "Circadian Calculator",
"info": "",
"category": "",
"in": [
{
"x": 60,
"y": 160,
"wires": [
{
"id": "aa4b86d8.b17118"
}
]
}
],
"out": [
{
"x": 1320,
"y": 120,
"wires": [
{
"id": "40de744.1e2ca8c",
"port": 0
}
]
},
{
"x": 1220,
"y": 340,
"wires": [
{
"id": "c26bdcca.eb483",
"port": 0
}
]
},
{
"x": 520,
"y": 400,
"wires": [
{
"id": "a330b219.92e4e",
"port": 0
}
]
}
],
"env": [],
"color": "#DDAA99"
},
{
"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": "early_morning",
"vt": "str"
},
{
"t": "eq",
"v": "morning",
"vt": "str"
},
{
"t": "eq",
"v": "afternoon",
"vt": "str"
},
{
"t": "eq",
"v": "evening",
"vt": "str"
},
{
"t": "eq",
"v": "late_evening",
"vt": "str"
}
],
"checkall": "true",
"repair": false,
"outputs": 6,
"x": 550,
"y": 240,
"wires": [
[
"840431b7.eeefc",
"ba17c1e6.e6f58"
],
[
"9dc0e41264f06501",
"6698ec4c9ecae4ae"
],
[
"e5bb5a04.a33948",
"d4d99259.d0d7e"
],
[
"7c0f0774.90adf8",
"6ac1af7.dddb15"
],
[
"23b260f9.19f78",
"a907f5f4.0bf488"
],
[
"62d4a1d160117fef",
"158c902643179f82"
]
]
},
{
"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.6
},
{
"x": 0.134,
"y": 0.221
},
{
"x": 0.297,
"y": 0.001
},
{
"x": 1,
"y": 0
}
],
"x": 790,
"y": 20,
"wires": [
[
"40de744.1e2ca8c"
]
]
},
{
"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.575
},
{
"x": 0.166,
"y": 0.74
},
{
"x": 0.333,
"y": 0.8
},
{
"x": 0.5,
"y": 0.831
},
{
"x": 0.666,
"y": 0.845
},
{
"x": 0.834,
"y": 0.855
},
{
"x": 1,
"y": 0.86
}
],
"x": 800,
"y": 100,
"wires": [
[
"40de744.1e2ca8c"
]
]
},
{
"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.66
},
{
"x": 0.35,
"y": 0.64
},
{
"x": 0.66,
"y": 0.64
},
{
"x": 0.997,
"y": 0.64
}
],
"x": 800,
"y": 180,
"wires": [
[
"40de744.1e2ca8c"
]
]
},
{
"id": "7c0f0774.90adf8",
"type": "spline-curve",
"z": "e812678d.651e28",
"name": "afternoon curve",
"output_key": "",
"input_key": "payload.times_of_day.active.perc",
"points": [
{
"x": 0,
"y": 0.86
},
{
"x": 0.143,
"y": 0.85
},
{
"x": 0.246,
"y": 0.85
},
{
"x": 0.429,
"y": 0.823
},
{
"x": 0.571,
"y": 0.792
},
{
"x": 0.714,
"y": 0.727
},
{
"x": 0.857,
"y": 0.65
},
{
"x": 0.99,
"y": 0.64
}
],
"x": 800,
"y": 140,
"wires": [
[
"40de744.1e2ca8c"
]
]
},
{
"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
},
{
"x": 0.28,
"y": 0
},
{
"x": 0.497,
"y": 0
}
],
"x": 790,
"y": 280,
"wires": [
[
"c26bdcca.eb483"
]
]
},
{
"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.46
},
{
"x": 0.166,
"y": 0.7
},
{
"x": 0.333,
"y": 0.8
},
{
"x": 0.5,
"y": 0.9
},
{
"x": 0.817,
"y": 1
},
{
"x": 1,
"y": 1
}
],
"x": 800,
"y": 360,
"wires": [
[
"c26bdcca.eb483"
]
]
},
{
"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.25
},
{
"x": 1,
"y": 0.12
}
],
"x": 800,
"y": 440,
"wires": [
[
"c26bdcca.eb483"
]
]
},
{
"id": "6ac1af7.dddb15",
"type": "spline-curve",
"z": "e812678d.651e28",
"name": "afternoon curve",
"output_key": "",
"input_key": "payload.times_of_day.active.perc",
"points": [
{
"x": 0,
"y": 1
},
{
"x": 0.428,
"y": 1
},
{
"x": 0.571,
"y": 0.92
},
{
"x": 0.714,
"y": 0.8
},
{
"x": 0.857,
"y": 0.55
},
{
"x": 1,
"y": 0.25
}
],
"x": 800,
"y": 400,
"wires": [
[
"c26bdcca.eb483"
]
]
},
{
"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 \n wakeUp = new Date(obj.times[\"civilDawn\"].ts)\n wakeUp.setHours(6)\n wakeUp.setMinutes(20)\n \n sleepDate = new Date(obj.times[\"sunsetStart\"].ts)\n sleepDate.setHours(22)\n sleepDate.setMinutes(15)\n \n if (name_start == \"astronomicalDawn\")\n {\n if (obj.times[\"astronomicalDawn\"].ts > wakeUp)\n {\n ret.start = wakeUp\n }\n \n else\n {\n ret.start = obj.times[name_start].ts;\n }\n }\n \n else if (name_start == \"sleepTime\")\n {\n ret.start = sleepDate\n }\n else\n {\n ret.start = obj.times[name_start].ts; \n }\n \n if (name_end == \"astronomicalDawn\")\n {\n if (obj.times[\"astronomicalDawn\"].ts > wakeUp)\n {\n ret.end = wakeUp \n }\n else \n {\n ret.end = obj.times[name_end].ts; \n }\n \n }\n else if (name_end == \"sleepTime\")\n {\n ret.end = sleepDate\n }\n else\n {\n ret.end = obj.times[name_end].ts; \n }\n \n \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\n\n\nprocessTimeOfDay('night', newmsg.payload, \"sleepTime\", \"astronomicalDawn\");\nprocessTimeOfDay('early_morning', newmsg.payload, \"astronomicalDawn\", \"goldenHourDawnEnd\");\nprocessTimeOfDay('morning', newmsg.payload, \"goldenHourDawnEnd\", \"solarNoon\");\nprocessTimeOfDay('afternoon', newmsg.payload, \"solarNoon\", \"sunsetStart\");\nprocessTimeOfDay('evening', newmsg.payload, \"sunsetStart\", \"astronomicalDusk\");\nprocessTimeOfDay('late_evening', newmsg.payload, \"astronomicalDusk\", \"sleepTime\");\n\nreturn newmsg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 290,
"y": 240,
"wires": [
[
"5de89261.4fb97c"
]
]
},
{
"id": "40de744.1e2ca8c",
"type": "range",
"z": "e812678d.651e28",
"minin": "0",
"maxin": "1",
"minout": "1",
"maxout": "100",
"action": "scale",
"round": true,
"property": "payload",
"name": "",
"x": 1180,
"y": 120,
"wires": [
[]
]
},
{
"id": "c26bdcca.eb483",
"type": "range",
"z": "e812678d.651e28",
"minin": "0",
"maxin": "1",
"minout": "2000",
"maxout": "5500",
"action": "scale",
"round": true,
"property": "payload",
"name": "",
"x": 1090,
"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": 190,
"y": 160,
"wires": [
[
"a330b219.92e4e"
]
]
},
{
"id": "158c902643179f82",
"type": "spline-curve",
"z": "e812678d.651e28",
"name": "late evening curve",
"output_key": "",
"input_key": "payload.times_of_day.active.perc",
"points": [
{
"x": 0,
"y": 0.64
},
{
"x": 0.5,
"y": 0.62
},
{
"x": 1,
"y": 0.6
}
],
"x": 810,
"y": 220,
"wires": [
[
"40de744.1e2ca8c"
]
]
},
{
"id": "62d4a1d160117fef",
"type": "spline-curve",
"z": "e812678d.651e28",
"name": "late evening curve",
"output_key": "",
"input_key": "payload.times_of_day.active.perc",
"points": [
{
"x": 0,
"y": 0.12
},
{
"x": 0.994,
"y": 0
}
],
"x": 810,
"y": 480,
"wires": [
[
"c26bdcca.eb483"
]
]
},
{
"id": "9dc0e41264f06501",
"type": "spline-curve",
"z": "e812678d.651e28",
"name": "early_morning curve",
"output_key": "",
"input_key": "payload.times_of_day.active.perc",
"points": [
{
"x": 0,
"y": 0.01
},
{
"x": 0.157,
"y": 0.148
},
{
"x": 0.367,
"y": 0.318
},
{
"x": 0.54,
"y": 0.488
},
{
"x": 0.99,
"y": 0.575
}
],
"x": 820,
"y": 60,
"wires": [
[
"40de744.1e2ca8c"
]
]
},
{
"id": "6698ec4c9ecae4ae",
"type": "spline-curve",
"z": "e812678d.651e28",
"name": "early_morning curve",
"output_key": "",
"input_key": "payload.times_of_day.active.perc",
"points": [
{
"x": 0,
"y": 0
},
{
"x": 0.333,
"y": 0.118
},
{
"x": 1,
"y": 0.46
}
],
"x": 820,
"y": 320,
"wires": [
[
"c26bdcca.eb483"
]
]
},
{
"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": ""
}
]
I withdraw my previous comment! You are not crazy after all!
I have not dug inside the splice curve, yet…