I saw a Dodow on Amazon and then on YouTube. https://www.youtube.com/watch?v=Z6Q7yhrv2bs
The idea is to synchronise your breathing with the light. It start with 11 breaths a minute and after 8 minutes slows to 5 breaths a minute.
I thought, I can do that with a Hue light, so I tried in NodeRed and the results, early days yet, is good.
Here is the NodeRed script. The nodes that turn the lights on and off will need to be modified for your setup.
[
{
“id”: “874b3bab.0c2928”,
“type”: “tab”,
“label”: “Hue for bed”,
“disabled”: false,
“info”: “”
},
{
“id”: “c63feb00.6cd608”,
“type”: “inject”,
“z”: “874b3bab.0c2928”,
“name”: “off”,
“topic”: “”,
“payload”: “off”,
“payloadType”: “str”,
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“x”: 130,
“y”: 160,
“wires”: [
[
“d1642459.6bb5f8”
]
]
},
{
“id”: “af8e22e0.d49e7”,
“type”: “api-call-service”,
“z”: “874b3bab.0c2928”,
“name”: “Light on”,
“server”: “f7a0cb3b.2a4c98”,
“service_domain”: “homeassistant”,
“service”: “turn_on”,
“data”: “{"entity_id":"light.bedroom","transition":3,"rgb_color":[10,10,255],"brightness":190}”,
“render_data”: false,
“mergecontext”: “”,
“output_location”: “payload”,
“output_location_type”: “msg”,
“x”: 804,
“y”: 95,
“wires”: [
]
},
{
“id”: “8ba022f3.cdeb6”,
“type”: “function”,
“z”: “874b3bab.0c2928”,
“name”: “Build delay”,
“func”: “const deltaDelay = 75.757576\nconst initDelay = 2730\nconst loops = 80\nconst delayList = \n\nconst waitFor = delay => new Promise(resolve => timer = setTimeout(resolve, delay));\nlet timer = {}\n\nlet time = initDelay\nlet onOff = false\n\n// We are starting so we have not been cancelled\nflow.set(‘cancelTimeout’,false);\n\nasync function sendMsgAfterDelay() {\n for (const item of delayList) {\n node.send( { "onOff": item.onOff ? "on" : "off", "transition": Math.trunc(item.time / 1000) });\n await waitFor(item.time);\n flow.set(‘timer’, timer)\n if(flow.get(‘cancelTimeout’)) {\n break;\n }\n }\n if(flow.get(‘cancelTimeout’) === false) {\n node.send( { "onOff": "lightoff", "transition": 0 })\n await waitFor(5000);\n node.send( { "onOff": "playmusic", "transition": 0 })\n }\n}\n\nfor (let loop = 0; loop < loops; loop++) {\n time += deltaDelay\n onOff = !onOff\n delayList.push({ time: time, onOff: onOff })\n}\nsendMsgAfterDelay()\n”,
“outputs”: 1,
“noerr”: 0,
“x”: 450,
“y”: 160,
“wires”: [
[
“6810a2b5.6d6e9c”
]
]
},
{
“id”: “7d7ea2e.38b8a5c”,
“type”: “api-call-service”,
“z”: “874b3bab.0c2928”,
“name”: “Light off”,
“server”: “f7a0cb3b.2a4c98”,
“service_domain”: “homeassistant”,
“service”: “turn_on”,
“data”: “{"entity_id":"light.bedroom","transition":3,"rgb_color":[10,10,255],"brightness":20}”,
“render_data”: false,
“mergecontext”: “”,
“output_location”: “payload”,
“output_location_type”: “msg”,
“x”: 804,
“y”: 155,
“wires”: [
]
},
{
“id”: “6810a2b5.6d6e9c”,
“type”: “switch”,
“z”: “874b3bab.0c2928”,
“name”: “On or Off”,
“property”: “onOff”,
“propertyType”: “msg”,
“rules”: [
{
“t”: “eq”,
“v”: “on”,
“vt”: “str”
},
{
“t”: “eq”,
“v”: “off”,
“vt”: “str”
},
{
“t”: “eq”,
“v”: “lightoff”,
“vt”: “str”
},
{
“t”: “eq”,
“v”: “playmusic”,
“vt”: “str”
}
],
“checkall”: “true”,
“repair”: false,
“outputs”: 4,
“x”: 600,
“y”: 160,
“wires”: [
[
“af8e22e0.d49e7”
],
[
“7d7ea2e.38b8a5c”
],
[
“8d73ddaf.ecc15”
],
[
“4ab38d3d.b28bb4”
]
]
},
{
“id”: “266a8537.6865da”,
“type”: “alexa-local”,
“z”: “874b3bab.0c2928”,
“devicename”: “bed time”,
“inputtrigger”: false,
“x”: 140,
“y”: 240,
“wires”: [
[
“d1642459.6bb5f8”
]
]
},
{
“id”: “2e842800.cd0db8”,
“type”: “debug”,
“z”: “874b3bab.0c2928”,
“name”: “”,
“active”: true,
“tosidebar”: true,
“console”: false,
“tostatus”: false,
“complete”: “true”,
“x”: 790,
“y”: 40,
“wires”:
},
{
“id”: “8d73ddaf.ecc15”,
“type”: “api-call-service”,
“z”: “874b3bab.0c2928”,
“name”: “Light off completely”,
“server”: “f7a0cb3b.2a4c98”,
“service_domain”: “homeassistant”,
“service”: “turn_off”,
“data”: “{"entity_id":"light.bedroom","transition":3}”,
“render_data”: false,
“mergecontext”: “”,
“output_location”: “payload”,
“output_location_type”: “msg”,
“x”: 834,
“y”: 220,
“wires”: [
]
},
{
“id”: “4ab38d3d.b28bb4”,
“type”: “api-call-service”,
“z”: “874b3bab.0c2928”,
“name”: “Play music”,
“server”: “f7a0cb3b.2a4c98”,
“service_domain”: “script”,
“service”: “play_ocean”,
“data”: “”,
“render_data”: false,
“mergecontext”: “”,
“output_location”: “payload”,
“output_location_type”: “msg”,
“x”: 814,
“y”: 280,
“wires”: [
]
},
{
“id”: “d1642459.6bb5f8”,
“type”: “switch”,
“z”: “874b3bab.0c2928”,
“name”: “on/off”,
“property”: “payload”,
“propertyType”: “msg”,
“rules”: [
{
“t”: “eq”,
“v”: “on”,
“vt”: “str”
},
{
“t”: “eq”,
“v”: “off”,
“vt”: “str”
}
],
“checkall”: “true”,
“repair”: false,
“outputs”: 2,
“x”: 290,
“y”: 212,
“wires”: [
[
“8ba022f3.cdeb6”
],
[
“c9b38e95.7091a”
]
]
},
{
“id”: “339dc57.e17bf3a”,
“type”: “inject”,
“z”: “874b3bab.0c2928”,
“name”: “on”,
“topic”: “”,
“payload”: “on”,
“payloadType”: “str”,
“repeat”: “”,
“crontab”: “”,
“once”: false,
“onceDelay”: 0.1,
“x”: 130,
“y”: 100,
“wires”: [
[
“d1642459.6bb5f8”
]
]
},
{
“id”: “c9b38e95.7091a”,
“type”: “function”,
“z”: “874b3bab.0c2928”,
“name”: “Cancel function”,
“func”: “// We have been called so we need to cancel\nflow.set(‘cancelTimeout’,true);\nclearTimeout(flow.get(‘timer’))\n”,
“outputs”: 1,
“noerr”: 0,
“x”: 580,
“y”: 220,
“wires”: [
[
“8d73ddaf.ecc15”
]
]
},
{
“id”: “f7a0cb3b.2a4c98”,
“type”: “server”,
“z”: “”,
“name”: “Home Assistant”
}
]