diff --git a/flows.json b/flows.json index 3f5bd4f..3748158 100644 --- a/flows.json +++ b/flows.json @@ -1218,8 +1218,8 @@ ], "x": 14, "y": 859, - "w": 792, - "h": 202 + "w": 612, + "h": 262 }, { "id": "550e5b2d99316b12", @@ -1851,8 +1851,8 @@ ], "x": 894, "y": 739, - "w": 792, - "h": 202 + "w": 612, + "h": 262 }, { "id": "0f7fdf39e4400032", @@ -2041,9 +2041,9 @@ "fa7c83f1dece9741" ], "x": 14, - "y": 1079, - "w": 972, - "h": 262 + "y": 1139, + "w": 792, + "h": 322 }, { "id": "5c1df7492351b925", @@ -2064,9 +2064,9 @@ "5524e8ba9b5545be" ], "x": 894, - "y": 959, - "w": 792, - "h": 202 + "y": 1019, + "w": 612, + "h": 262 }, { "id": "505e378279011759", @@ -2087,9 +2087,9 @@ "81129efa6676b58e" ], "x": 894, - "y": 1179, - "w": 792, - "h": 202 + "y": 1299, + "w": 612, + "h": 262 }, { "id": "fba69dfc80829db7", @@ -10640,7 +10640,7 @@ "output_location": "", "output_location_type": "none", "x": 530, - "y": 1020, + "y": 1080, "wires": [ [] ] @@ -10849,8 +10849,8 @@ "z": "eff21041cc941fef", "g": "8aee4d340a136bac", "name": "Delay", - "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst lights = states['light.downstairs_bathroom_lights'].state\nconst duration = states['input_number.downstairs_bathroom_lights_off_delay'].state\nconst lux = parseInt(states['sensor.downstairs_bathroom_illuminance'].state)\nconst threshold = parseInt(states['input_number.downstairs_bathroom_lux_threshold'].state)\nconst payload = msg.payload\nconst newDuration = duration * 60\n\nif (payload === 'on') {\n if (lux <= threshold && lights === 'off') {\n node.status({fill:'green',shape:'dot',text:'Turning lights on'})\n node.send([msg,null])\n } else {\n if (lights === 'on') {\n node.status({fill:'red',shape:'ring',text:'Lights already on'})\n } else {\n node.status({fill:'red',shape:'ring',text:'Too bright'})\n }\n }\n} else if (payload === 'off') {\n if (lights === 'on') {\n msg.duration = newDuration\n node.status({fill:\"green\",shape:\"dot\",text:parseInt(duration) + ' minutes'})\n node.send([null,msg])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Lights already off\"})\n }\n}", - "outputs": 2, + "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst lights = states['light.downstairs_bathroom_lights'].state\nconst duration = states['input_number.downstairs_bathroom_lights_off_delay'].state\nconst lux = parseInt(states['sensor.downstairs_bathroom_illuminance'].state)\nconst threshold = parseInt(states['input_number.downstairs_bathroom_lux_threshold'].state)\nconst payload = msg.payload\nconst newDuration = duration * 60\n\nif (payload === 'on') {\n if (lux <= threshold && lights === 'off') {\n node.status({fill:'green',shape:'dot',text:'Turning lights on'})\n node.send([msg,msg,null])\n } else {\n if (lights === 'on') {\n node.status({fill:'red',shape:'ring',text:'Lights already on'})\n node.send([null,msg,null])\n } else {\n node.status({fill:'red',shape:'ring',text:'Too bright'})\n }\n }\n} else if (payload === 'off') {\n if (lights === 'on') {\n msg.duration = newDuration\n node.status({fill:\"green\",shape:\"dot\",text:parseInt(duration) + ' minutes'})\n node.send([null,null,msg])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Lights already off\"})\n }\n}", + "outputs": 3, "timeout": "", "noerr": 0, "initialize": "", @@ -10862,10 +10862,18 @@ [ "b281061a4b08d2eb" ], + [ + "41a8d5ef20cf55d7" + ], [ "b7d94cd0e420c650" ] ], + "outputLabels": [ + "Lights On", + "Cancel Timer", + "Start Timer" + ], "icon": "node-red/timer.svg" }, { @@ -10895,7 +10903,7 @@ "domain": "timer", "service": "start", "x": 530, - "y": 960, + "y": 1020, "wires": [ [] ] @@ -10926,8 +10934,8 @@ "blockInputOverrides": false, "domain": "timer", "service": "cancel", - "x": 710, - "y": 900, + "x": 530, + "y": 960, "wires": [ [] ] @@ -10953,7 +10961,7 @@ } ], "x": 120, - "y": 1020, + "y": 1080, "wires": [ [ "5123a607588fa737" @@ -11045,9 +11053,7 @@ "x": 520, "y": 900, "wires": [ - [ - "41a8d5ef20cf55d7" - ] + [] ] }, { @@ -11876,7 +11882,7 @@ } ], "x": 110, - "y": 1180, + "y": 1240, "wires": [ [ "7c4cc52be117251f" @@ -11892,23 +11898,31 @@ "z": "eff21041cc941fef", "g": "ab4dbcc968a1d346", "name": "Delay", - "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst lights = states['light.mud_room_overhead'].state\nconst selScene = states['input_text.mud_room_selected_scene'].state\nconst duration = states['input_number.mud_room_lights_off_delay'].state\nconst lux = parseInt(states['sensor.mud_room_illuminance'].state)\nconst threshold = parseInt(states['input_number.mud_room_lux_threshold'].state)\nconst payload = msg.payload\nconst newDuration = duration * 60\n\nif (payload === 'on') {\n if (lux <= threshold && (lights === 'off' || selScene === 'Nightlight')) {\n node.status({fill:'green',shape:'dot',text:'Turning lights on'})\n node.send([msg,null])\n } else {\n if (lights === 'on') {\n node.status({fill:'red',shape:'ring',text:'Lights already on'})\n } else {\n node.status({fill:'red',shape:'ring',text:'Too bright'})\n }\n }\n} else if (payload === 'off') {\n if (lights === 'on') {\n msg.duration = newDuration\n node.status({fill:\"green\",shape:\"dot\",text:parseInt(duration) + ' minutes'})\n node.send([null,msg])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Lights already off\"})\n }\n}", - "outputs": 2, + "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst lights = states['light.mud_room_overhead'].state\nconst selScene = states['input_text.mud_room_selected_scene'].state\nconst duration = states['input_number.mud_room_lights_off_delay'].state\nconst lux = parseInt(states['sensor.mud_room_illuminance'].state)\nconst threshold = parseInt(states['input_number.mud_room_lux_threshold'].state)\nconst payload = msg.payload\nconst newDuration = duration * 60\n\nif (payload === 'on') {\n if (lux <= threshold && (lights === 'off' || selScene === 'Nightlight')) {\n node.status({fill:'green',shape:'dot',text:'Turning lights on'})\n node.send([msg,msg,null])\n } else {\n if (lights === 'on') {\n node.status({fill:'red',shape:'ring',text:'Lights already on'})\n node.send([null,msg,null])\n } else {\n node.status({fill:'red',shape:'ring',text:'Too bright'})\n }\n }\n} else if (payload === 'off') {\n if (lights === 'on') {\n msg.duration = newDuration\n node.status({fill:\"green\",shape:\"dot\",text:parseInt(duration) + ' minutes'})\n node.send([null,null,msg])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Lights already off\"})\n }\n}", + "outputs": 3, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 270, - "y": 1180, + "y": 1240, "wires": [ [ "67d04dc394a23636" ], + [ + "ddae3391e8b78cb8" + ], [ "0c70e666ebfcd6c1" ] ], + "outputLabels": [ + "Lights On", + "Cancel Timer", + "Start Timer" + ], "icon": "node-red/timer.svg" }, { @@ -11938,11 +11952,9 @@ "domain": "input_select", "service": "select_option", "x": 700, - "y": 1120, + "y": 1180, "wires": [ - [ - "ddae3391e8b78cb8" - ] + [] ] }, { @@ -11971,8 +11983,8 @@ "blockInputOverrides": false, "domain": "timer", "service": "cancel", - "x": 890, - "y": 1120, + "x": 530, + "y": 1240, "wires": [ [] ] @@ -12004,7 +12016,7 @@ "domain": "timer", "service": "start", "x": 530, - "y": 1180, + "y": 1300, "wires": [ [] ] @@ -12036,7 +12048,7 @@ "domain": "light", "service": "turn_on", "x": 520, - "y": 1120, + "y": 1180, "wires": [ [ "a7cd304d11f25e60" @@ -12072,7 +12084,7 @@ "output_location": "", "output_location_type": "none", "x": 530, - "y": 1300, + "y": 1420, "wires": [ [] ] @@ -12098,7 +12110,7 @@ } ], "x": 120, - "y": 1240, + "y": 1360, "wires": [ [ "5d9a85d3534d83e6" @@ -12137,7 +12149,7 @@ "entity_location": "data", "override_data": "msg", "x": 330, - "y": 1240, + "y": 1360, "wires": [ [ "fa7c83f1dece9741" @@ -12174,7 +12186,7 @@ "domain": "input_select", "service": "select_option", "x": 540, - "y": 1240, + "y": 1360, "wires": [ [] ] @@ -13453,7 +13465,7 @@ "output_location": "", "output_location_type": "none", "x": 1410, - "y": 900, + "y": 960, "wires": [ [] ] @@ -13464,8 +13476,8 @@ "z": "5e238cbbe6d612c9", "g": "ba738e13229c781b", "name": "Delay", - "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst lights = states['light.emma_bedroom_light'].state\nconst duration = states['input_number.emma_bedroom_lights_off_delay'].state\nconst lux = parseInt(states['sensor.emma_bedroom_illuminance'].state)\nconst threshold = parseInt(states['input_number.emma_bedroom_lux_threshold'].state)\nconst sleeping = states['input_boolean.emma_sleeping'].state\nconst payload = msg.payload\nconst newDuration = duration * 60\n\nif (sleeping === 'off') {\n if (payload === 'on') {\n if (lux <= threshold && lights === 'off') {\n node.status({fill:'green',shape:'dot',text:'Turning lights on'})\n node.send([msg,null])\n } else {\n if (lights === 'off') {\n node.status({fill:'red',shape:'ring',text:'Lights already on'})\n } else {\n node.status({fill:'red',shape:'ring',text:'Too bright'})\n }\n }\n } else if (payload === 'off') {\n if (lights === 'on') {\n msg.duration = newDuration\n node.status({fill:\"green\",shape:\"dot\",text:parseInt(duration) + ' minutes'})\n node.send([null,msg])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Lights already off\"})\n }\n }\n} else {\n node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'})\n}", - "outputs": 2, + "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst lights = states['light.emma_bedroom_light'].state\nconst duration = states['input_number.emma_bedroom_lights_off_delay'].state\nconst lux = parseInt(states['sensor.emma_bedroom_illuminance'].state)\nconst threshold = parseInt(states['input_number.emma_bedroom_lux_threshold'].state)\nconst sleeping = states['input_boolean.emma_sleeping'].state\nconst payload = msg.payload\nconst newDuration = duration * 60\n\nif (sleeping === 'off') {\n if (payload === 'on') {\n if (lux <= threshold && lights === 'off') {\n node.status({fill:'green',shape:'dot',text:'Turning lights on'})\n node.send([msg,msg,null])\n } else {\n if (lights === 'on') {\n node.status({fill:'red',shape:'ring',text:'Lights already on'})\n node.send([null,msg,null])\n } else {\n node.status({fill:'red',shape:'ring',text:'Too bright'})\n }\n }\n } else if (payload === 'off') {\n if (lights === 'on') {\n msg.duration = newDuration\n node.status({fill:\"green\",shape:\"dot\",text:parseInt(duration) + ' minutes'})\n node.send([null,null,msg])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Lights already off\"})\n }\n }\n} else {\n node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'})\n}", + "outputs": 3, "timeout": "", "noerr": 0, "initialize": "", @@ -13477,10 +13489,18 @@ [ "440fc7142e7345d4" ], + [ + "b058c2262ac522ff" + ], [ "55c893b1d3009fed" ] ], + "outputLabels": [ + "Lights On", + "Cancel Timer", + "Start Timer" + ], "icon": "node-red/timer.svg" }, { @@ -13510,7 +13530,7 @@ "domain": "timer", "service": "start", "x": 1410, - "y": 840, + "y": 900, "wires": [ [] ] @@ -13541,8 +13561,8 @@ "blockInputOverrides": false, "domain": "timer", "service": "cancel", - "x": 1590, - "y": 780, + "x": 1410, + "y": 840, "wires": [ [] ] @@ -13568,7 +13588,7 @@ } ], "x": 1000, - "y": 900, + "y": 960, "wires": [ [ "cef61cdb2808ce5a" @@ -13660,9 +13680,7 @@ "x": 1400, "y": 780, "wires": [ - [ - "b058c2262ac522ff" - ] + [] ] }, { @@ -13697,7 +13715,7 @@ "entity_location": "data", "override_data": "msg", "x": 1210, - "y": 900, + "y": 960, "wires": [ [ "c3f2a4aa281295ce" @@ -13996,7 +14014,7 @@ "output_location": "", "output_location_type": "none", "x": 1410, - "y": 1120, + "y": 1240, "wires": [ [] ] @@ -14007,23 +14025,31 @@ "z": "5e238cbbe6d612c9", "g": "5c1df7492351b925", "name": "Delay", - "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst lights = states['light.kallen_bedroom_lights'].state\nconst duration = states['input_number.kallen_bedroom_lights_off_delay'].state\nconst lux = parseInt(states['sensor.kallen_bedroom_illuminance'].state)\nconst threshold = parseInt(states['input_number.kallen_bedroom_lux_threshold'].state)\nconst sleeping = states['input_boolean.kallen_sleeping'].state\nconst payload = msg.payload\nconst newDuration = duration * 60\n\nif (sleeping === 'off') {\n if (payload === 'on') {\n if (lux <= threshold && lights === 'off') {\n node.status({fill:'green',shape:'dot',text:'Turning lights on'})\n node.send([msg,null])\n } else {\n if (lights === 'off') {\n node.status({fill:'red',shape:'ring',text:'Lights already on'})\n } else {\n node.status({fill:'red',shape:'ring',text:'Too bright'})\n }\n }\n } else if (payload === 'off') {\n if (lights === 'on') {\n msg.duration = newDuration\n node.status({fill:\"green\",shape:\"dot\",text:parseInt(duration) + ' minutes'})\n node.send([null,msg])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Lights already off\"})\n }\n }\n} else {\n node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'})\n}", - "outputs": 2, + "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst lights = states['light.kallen_bedroom_lights'].state\nconst duration = states['input_number.kallen_bedroom_lights_off_delay'].state\nconst lux = parseInt(states['sensor.kallen_bedroom_illuminance'].state)\nconst threshold = parseInt(states['input_number.kallen_bedroom_lux_threshold'].state)\nconst sleeping = states['input_boolean.kallen_sleeping'].state\nconst payload = msg.payload\nconst newDuration = duration * 60\n\nif (sleeping === 'off') {\n if (payload === 'on') {\n if (lux <= threshold && lights === 'off') {\n node.status({fill:'green',shape:'dot',text:'Turning lights on'})\n node.send([msg,msg,null])\n } else {\n if (lights === 'on') {\n node.status({fill:'red',shape:'ring',text:'Lights already on'})\n node.send([null,msg,null])\n } else {\n node.status({fill:'red',shape:'ring',text:'Too bright'})\n }\n }\n } else if (payload === 'off') {\n if (lights === 'on') {\n msg.duration = newDuration\n node.status({fill:\"green\",shape:\"dot\",text:parseInt(duration) + ' minutes'})\n node.send([null,null,msg])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Lights already off\"})\n }\n }\n} else {\n node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'})\n}", + "outputs": 3, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1150, - "y": 1060, + "y": 1120, "wires": [ [ "5524e8ba9b5545be" ], + [ + "bbe9fd4eff4e6a04" + ], [ "9a8f53db7d3ed3b7" ] ], + "outputLabels": [ + "Lights On", + "Cancel Timer", + "Start Timer" + ], "icon": "node-red/timer.svg" }, { @@ -14053,7 +14079,7 @@ "domain": "timer", "service": "start", "x": 1410, - "y": 1060, + "y": 1180, "wires": [ [] ] @@ -14084,8 +14110,8 @@ "blockInputOverrides": false, "domain": "timer", "service": "cancel", - "x": 1590, - "y": 1000, + "x": 1410, + "y": 1120, "wires": [ [] ] @@ -14111,7 +14137,7 @@ } ], "x": 1000, - "y": 1120, + "y": 1240, "wires": [ [ "0b5424aadc3479f7" @@ -14164,7 +14190,7 @@ } ], "x": 990, - "y": 1060, + "y": 1120, "wires": [ [ "4954c509d4d697e2" @@ -14206,7 +14232,7 @@ "entity_location": "data", "override_data": "msg", "x": 1210, - "y": 1120, + "y": 1240, "wires": [ [ "f3824e4c7e202605" @@ -14241,11 +14267,9 @@ "domain": "input_select", "service": "select_option", "x": 1400, - "y": 1000, + "y": 1060, "wires": [ - [ - "bbe9fd4eff4e6a04" - ] + [] ] }, { @@ -14277,7 +14301,7 @@ "output_location": "", "output_location_type": "none", "x": 1410, - "y": 1340, + "y": 1520, "wires": [ [] ] @@ -14288,23 +14312,31 @@ "z": "5e238cbbe6d612c9", "g": "505e378279011759", "name": "Delay", - "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst lights = states['light.master_bedroom_lights'].state\nconst duration = states['input_number.master_bedroom_lights_off_delay'].state\nconst lux = parseInt(states['sensor.master_bedroom_illuminance'].state)\nconst threshold = parseInt(states['input_number.master_bedroom_lux_threshold'].state)\nconst masterBedroomSleep = states['input_boolean.master_bedroom_sleeping'].state\nconst kallenBedroomSleep = states['input_boolean.kallen_sleeping'].state\nconst peopleSleeping = (masterBedroomSleep === 'on' || kallenBedroomSleep === 'on')\nconst nightMode = states['input_boolean.night_mode'].state\nconst payload = msg.payload\nconst newDuration = duration * 60\n\nif (peopleSleeping === false && nightMode === 'off') {\n if (payload === 'on') {\n if (lux <= threshold && lights === 'off') {\n node.status({fill:'green',shape:'dot',text:'Turning lights on'})\n node.send([msg,null])\n } else {\n if (lights === 'off') {\n node.status({fill:'red',shape:'ring',text:'Lights already on'})\n } else {\n node.status({fill:'red',shape:'ring',text:'Too bright'})\n }\n }\n } else if (payload === 'off') {\n if (lights === 'on') {\n msg.duration = newDuration\n node.status({fill:\"green\",shape:\"dot\",text:parseInt(duration) + ' minutes'})\n node.send([null,msg])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Lights already off\"})\n }\n }\n} else {\n node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'})\n}", - "outputs": 2, + "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst lights = states['light.master_bedroom_lights'].state\nconst duration = states['input_number.master_bedroom_lights_off_delay'].state\nconst lux = parseInt(states['sensor.master_bedroom_illuminance'].state)\nconst threshold = parseInt(states['input_number.master_bedroom_lux_threshold'].state)\nconst masterBedroomSleep = states['input_boolean.master_bedroom_sleeping'].state\nconst kallenBedroomSleep = states['input_boolean.kallen_sleeping'].state\nconst peopleSleeping = (masterBedroomSleep === 'on' || kallenBedroomSleep === 'on')\nconst nightMode = states['input_boolean.night_mode'].state\nconst payload = msg.payload\nconst newDuration = duration * 60\n\nif (peopleSleeping === false && nightMode === 'off') {\n if (payload === 'on') {\n if (lux <= threshold && lights === 'off') {\n node.status({fill:'green',shape:'dot',text:'Turning lights on'})\n node.send([msg,msg,null])\n } else {\n if (lights === 'on') {\n node.status({fill:'red',shape:'ring',text:'Lights already on'})\n node.send([null,msg,null])\n } else {\n node.status({fill:'red',shape:'ring',text:'Too bright'})\n }\n }\n } else if (payload === 'off') {\n if (lights === 'on') {\n msg.duration = newDuration\n node.status({fill:\"green\",shape:\"dot\",text:parseInt(duration) + ' minutes'})\n node.send([null,null,msg])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Lights already off\"})\n }\n }\n} else {\n node.status({fill:'red',shape:'ring',text:'Blocked (Sleeping)'})\n}", + "outputs": 3, "timeout": "", "noerr": 0, "initialize": "", "finalize": "", "libs": [], "x": 1150, - "y": 1280, + "y": 1400, "wires": [ [ "81129efa6676b58e" ], + [ + "f14572686bbbbf9e" + ], [ "31686303c43971c7" ] ], + "outputLabels": [ + "Lights On", + "Cancel Timer", + "Start Timer" + ], "icon": "node-red/timer.svg" }, { @@ -14334,7 +14366,7 @@ "domain": "timer", "service": "start", "x": 1410, - "y": 1280, + "y": 1460, "wires": [ [] ] @@ -14365,8 +14397,8 @@ "blockInputOverrides": false, "domain": "timer", "service": "cancel", - "x": 1590, - "y": 1220, + "x": 1410, + "y": 1400, "wires": [ [] ] @@ -14392,7 +14424,7 @@ } ], "x": 1000, - "y": 1340, + "y": 1520, "wires": [ [ "4a431478798a51c8" @@ -14445,7 +14477,7 @@ } ], "x": 990, - "y": 1280, + "y": 1400, "wires": [ [ "3063e6a5b5c3f677" @@ -14487,7 +14519,7 @@ "entity_location": "data", "override_data": "msg", "x": 1210, - "y": 1340, + "y": 1520, "wires": [ [ "e270c73896a1a50c" @@ -14522,11 +14554,9 @@ "domain": "input_select", "service": "select_option", "x": 1400, - "y": 1220, + "y": 1340, "wires": [ - [ - "f14572686bbbbf9e" - ] + [] ] }, {