From c118f2fdb277b2057b8fdab9b3d0f15608619394 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 21 Aug 2023 15:44:30 -0400 Subject: [PATCH] Further simplification of master bedroom climate flow #3 --- flows.json | 341 +++++++++++------------------------------------------ 1 file changed, 72 insertions(+), 269 deletions(-) diff --git a/flows.json b/flows.json index 6707edb..9e9ca30 100644 --- a/flows.json +++ b/flows.json @@ -762,17 +762,12 @@ "8e399b2a287a0905", "314752dbc6fd170d", "d7261338e6b907f1", - "fd0a309681a536de", "bf1b0d6542ef6b38", - "20f407c978d14863", - "444acaf315688ac9", "dc440dfc78c41b8a", "1aa901d26ce8ac46", "21001f5409130f44", "bc592ba259667f9d", "1f7ac875e593d434", - "9179e99207e9f8f3", - "404c42d6fea46839", "7a7f626dce181b23", "f541ad53e32f703b", "66e85878d60c7d65", @@ -784,13 +779,10 @@ "1dfb0bcc98f1457b", "096369136e9e607f", "783cfb381b70afc5", - "0f6d425791646818", - "67509a5554fc091f", "1eb13d819ba7e226", "a10629857d60f774", "a3ef2faca9922113", "a8ef744455bb4c0a", - "6ed7feb3956038ed", "9c01880c6319d29b", "94c022d2eb71e7d5", "ce5d8005cbf08144", @@ -801,11 +793,12 @@ "8286284fc9598efa", "53c58cce51d4596a", "ce204e8dd5784824", - "26f2f56e5abe7f25" + "26f2f56e5abe7f25", + "cbe37fd5b5fc4381" ], "x": 14, "y": 19, - "w": 1352, + "w": 1252, "h": 682 }, { @@ -988,7 +981,9 @@ "f111c40459e27629" ], "x": 34, - "y": 19 + "y": 19, + "w": 1272, + "h": 502 }, { "id": "208284848b13b85b", @@ -1311,7 +1306,9 @@ "e59180a1a6ae0a90" ], "x": 1094, - "y": 659 + "y": 659, + "w": 632, + "h": 82 }, { "id": "265593f442864b6a", @@ -1551,7 +1548,9 @@ "8146f43fea5aec03" ], "x": 34, - "y": 539 + "y": 539, + "w": 1192, + "h": 502 }, { "id": "b9ffa3fa5af46ec3", @@ -16205,7 +16204,7 @@ "friday": true, "saturday": true, "debugenabled": false, - "x": 160, + "x": 180, "y": 280, "wires": [ [ @@ -16281,66 +16280,6 @@ ] ] }, - { - "id": "fd0a309681a536de", - "type": "api-call-service", - "z": "72f99805df043603", - "g": "e065b1ed4938b477", - "name": "Set to Cool", - "server": "9e87348d.9c1c48", - "version": 5, - "debugenabled": false, - "domain": "climate", - "service": "set_hvac_mode", - "areaId": [], - "deviceId": [], - "entityId": [ - "climate.master_bedroom_aircon" - ], - "data": "{\t \"hvac_mode\": hvac\t}", - "dataType": "jsonata", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "x": 750, - "y": 260, - "wires": [ - [ - "20f407c978d14863" - ] - ] - }, - { - "id": "444acaf315688ac9", - "type": "api-call-service", - "z": "72f99805df043603", - "g": "e065b1ed4938b477", - "name": "Set Temp", - "server": "9e87348d.9c1c48", - "version": 5, - "debugenabled": false, - "domain": "climate", - "service": "set_temperature", - "areaId": [], - "deviceId": [], - "entityId": [ - "climate.master_bedroom_aircon" - ], - "data": "{\t \"temperature\": temp\t}", - "dataType": "jsonata", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "x": 1080, - "y": 220, - "wires": [ - [ - "0f6d425791646818" - ] - ] - }, { "id": "bf1b0d6542ef6b38", "type": "api-call-service", @@ -16369,36 +16308,6 @@ [] ] }, - { - "id": "20f407c978d14863", - "type": "api-call-service", - "z": "72f99805df043603", - "g": "e065b1ed4938b477", - "name": "Eco Set", - "server": "9e87348d.9c1c48", - "version": 5, - "debugenabled": false, - "domain": "climate", - "service": "set_preset_mode", - "areaId": [], - "deviceId": [], - "entityId": [ - "climate.master_bedroom_aircon" - ], - "data": "{\t \"preset_mode\": eco\t}", - "dataType": "jsonata", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "x": 920, - "y": 240, - "wires": [ - [ - "444acaf315688ac9" - ] - ] - }, { "id": "d5784e5baa80a105", "type": "ha-time", @@ -16826,36 +16735,6 @@ ] ] }, - { - "id": "9179e99207e9f8f3", - "type": "api-call-service", - "z": "72f99805df043603", - "g": "e065b1ed4938b477", - "name": "Set Temp", - "server": "9e87348d.9c1c48", - "version": 5, - "debugenabled": false, - "domain": "climate", - "service": "set_temperature", - "areaId": [], - "deviceId": [], - "entityId": [ - "climate.master_bedroom_aircon" - ], - "data": "{\t \"temperature\": bedtemp\t}", - "dataType": "jsonata", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "x": 720, - "y": 60, - "wires": [ - [ - "6ed7feb3956038ed" - ] - ] - }, { "id": "1f7ac875e593d434", "type": "ha-button", @@ -16880,17 +16759,23 @@ "valueType": "str" }, { - "property": "data", + "property": "time", "propertyType": "msg", - "value": "", - "valueType": "entity" + "value": "bedtime", + "valueType": "str" + }, + { + "property": "type", + "propertyType": "msg", + "value": "manual", + "valueType": "str" } ], - "x": 130, - "y": 120, + "x": 190, + "y": 160, "wires": [ [ - "a3ef2faca9922113" + "a10629857d60f774" ] ] }, @@ -16903,41 +16788,11 @@ "links": [ "028351e8c4e2faf5" ], - "x": 195, - "y": 60, + "x": 265, + "y": 100, "wires": [ [ - "a3ef2faca9922113" - ] - ] - }, - { - "id": "404c42d6fea46839", - "type": "api-call-service", - "z": "72f99805df043603", - "g": "e065b1ed4938b477", - "name": "Set to Cool", - "server": "9e87348d.9c1c48", - "version": 5, - "debugenabled": false, - "domain": "climate", - "service": "set_hvac_mode", - "areaId": [], - "deviceId": [], - "entityId": [ - "climate.master_bedroom_aircon" - ], - "data": "{\t \"hvac_mode\":\"cool\"\t}", - "dataType": "jsonata", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "x": 530, - "y": 120, - "wires": [ - [ - "9179e99207e9f8f3" + "a10629857d60f774" ] ] }, @@ -17191,62 +17046,6 @@ ] ] }, - { - "id": "0f6d425791646818", - "type": "api-call-service", - "z": "72f99805df043603", - "g": "e065b1ed4938b477", - "name": "Set Fan to Auto", - "server": "9e87348d.9c1c48", - "version": 5, - "debugenabled": false, - "domain": "climate", - "service": "set_fan_mode", - "areaId": [], - "deviceId": [], - "entityId": [ - "climate.master_bedroom_aircon" - ], - "data": "{\t \"fan_mode\":\"Auto\"\t}", - "dataType": "jsonata", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "x": 1260, - "y": 200, - "wires": [ - [] - ] - }, - { - "id": "67509a5554fc091f", - "type": "api-call-service", - "z": "72f99805df043603", - "g": "e065b1ed4938b477", - "name": "Set Fan to Auto", - "server": "9e87348d.9c1c48", - "version": 5, - "debugenabled": false, - "domain": "climate", - "service": "set_fan_mode", - "areaId": [], - "deviceId": [], - "entityId": [ - "climate.master_bedroom_aircon" - ], - "data": "{\t \"fan_mode\":\"Auto\"\t}", - "dataType": "jsonata", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "x": 1060, - "y": 60, - "wires": [ - [] - ] - }, { "id": "57651381835f659c", "type": "api-current-state", @@ -17657,7 +17456,7 @@ "z": "72f99805df043603", "g": "e065b1ed4938b477", "name": "Processing", - "func": "// pull in the necessary information\n\nconst states = global.get('homeassistant.homeAssistant.states')\nconst allowed = states['input_boolean.master_bedroom_nighttime_protocol'].state\nconst ac = global.get('mb_aircon_installed')\nconst temp = global.get(\"tempStr\")\nconst time = msg.time\nconst type = msg.type\nconst topic = msg.topic\nconst vacation = states['input_boolean.vacation_mode'].state\nconst highTemp = states['sensor.today_corrected_high_temp'].state\nconst dayTemp = states['input_number.master_bedroom_daytime_temp'].state\nconst nightTemp = states['input_number.master_bedroom_night_temp'].state\nconst bedTemp = states['input_number.master_bedroom_bedtime_temp'].state\nconst showerMode = states['input_boolean.shower_mode'].state\nconst nightVolume = states['input_number.master_bedroom_echo_dot_night_volume'].state\nconst fanMode = states['input_select.scheduled_climate_mode_master_bedroom_fan'].state\nconst acMode = states['input_select.scheduled_climate_mode_master_bedroom_aircon'].state\nconst sleeping = states['input_boolean.master_bedroom_sleeping'].state\nconst hotDay = states['input_boolean.hot_day'].state\nconst heatWarning = states[\"binary_sensor.heat_warning\"].state\nconst showerCooldown = states[\"timer.shower_mode_cooldown\"].state\nconst earlyNight = states[\"binary_sensor.early_night_mode\"].state\n\n// define variables\n\nlet setTemp = []\nlet setEco = []\nlet setHvac = []\nlet setFan = []\nlet setBool = []\n\n// decision logic\n\nif (time === 'day') {\n if (type === 'auto') {\n setBool = 'off'\n }\n if (earlyNight === 'off') {\n setFan = \"off\"\n if (ac === 'on') {\n if (hotDay === 'on' || heatWarning === 'on') {\n setTemp = dayTemp\n setEco = \"eco\"\n setHvac = \"cool\"\n } else {\n setTemp = nightTemp\n setEco = \"eco\"\n setHvac = \"off\"\n }\n }\n } else if (earlyNight === 'on') {\n setTemp = nightTemp \n if (fanMode === 'Fan') {\n setFan = 'on'\n } else {\n setFan = 'off'\n }\n if (acMode === 'AC') {\n setHvac = 'cool'\n } else if (acMode === 'fan') {\n setHvac = 'fan_only'\n } else {\n setHvac = 'off'\n }\n if (hotDay === 'on'){\n setEco = 'off'\n } else {\n setEco = 'on'\n }\n }\n} else if (time === 'night') {\n if (type === 'auto') {\n setBool = 'on'\n }\n if (ac === 'on') {\n setTemp = nightTemp\n if (acMode === 'AC') {\n setEco = 'eco'\n setHvac = 'cool'\n if (hotDay === 'on' || sleeping === 'on') {\n setEco = 'none'\n }\n } else if (acMode === 'Fan') {\n setHvac = 'fan_only'\n } else {\n setHvac = 'off'\n }\n }\n if (fanMode === 'Fan') {\n setFan = 'on'\n } else {\n setFan = 'off'\n }\n}\n\nlet acSettings = {\n \"temp\": setTemp,\n \"eco\": setEco,\n \"hvac\": setHvac\n}\n\nlet fanSettings = {\n \"fan\": setFan\n}\n\nlet boolSettings = {\n \"bool\": setBool\n}\n\nlet notify = {\n \"topic\": topic,\n \"nighttemp\": nightTemp,\n \"acmode\": acMode,\n \"fanmode\": fanMode\n}\n\nif (type === 'auto') {\n node.send([null,null,boolSettings])\n}\n\nif ((type === 'auto' && allowed === 'on') || type === 'manual') {\n if (sleeping === 'on' && type === 'auto') {\n node.status({fill:\"red\",shape:\"ring\",text: \"Blocked (sleep mode)\"})\n } else if (vacation === 'off') {\n if (topic === 'mrbedroom-cooling' && ac === 'on') {\n node.status({fill:\"green\",shape:\"dot\",text:\"Cooling Schedule\"})\n node.send([acSettings,null,null]);\n } else if (topic === 'manual-night') {\n if (fanMode === 'Fan') {\n node.status({fill:\"blue\",shape:\"dot\",text:\"Manual Night (Fan)\"})\n node.send([null,fanSettings,null])\n } else {\n node.status({fill:\"blue\",shape:\"dot\",text:\"Manual Night (No Fan)\"})\n node.send([null,fanSettings,null])\n }\n } else if (topic === 'mrbedroom-fan' && fanMode == 'Fan') {\n node.status({fill:\"green\",shape:\"dot\",text:\"Fan Schedule\"})\n node.send([null,fanSettings,null])\n } else if (topic === 'mrbedroom-wakeup') {\n node.status({fill:\"green\",shape:\"dot\",text:\"Wakeup Schedule\"})\n node.send([acSettings,fanSettings,null])\n } else if (topic === 'manual-day') {\n node.status({fill:\"blue\",shape:\"dot\",text:\"Manual Day\"})\n node.send([acSettings,fanSettings,null])\n }\n }\n} else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Automation Disabled\"})\n}\n", + "func": "// pull in the necessary information\n\nconst states = global.get('homeassistant.homeAssistant.states')\nconst allowed = states['input_boolean.master_bedroom_nighttime_protocol'].state\nconst ac = global.get('mb_aircon_installed')\nconst temp = global.get(\"tempStr\")\nconst time = msg.time\nconst type = msg.type\nconst topic = msg.topic\nconst vacation = states['input_boolean.vacation_mode'].state\nconst highTemp = states['sensor.today_corrected_high_temp'].state\nconst dayTemp = states['input_number.master_bedroom_daytime_temp'].state\nconst nightTemp = states['input_number.master_bedroom_night_temp'].state\nconst bedTemp = states['input_number.master_bedroom_bedtime_temp'].state\nconst showerMode = states['input_boolean.shower_mode'].state\nconst nightVolume = states['input_number.master_bedroom_echo_dot_night_volume'].state\nconst fanMode = states['input_select.scheduled_climate_mode_master_bedroom_fan'].state\nconst acMode = states['input_select.scheduled_climate_mode_master_bedroom_aircon'].state\nconst sleeping = states['input_boolean.master_bedroom_sleeping'].state\nconst hotDay = states['input_boolean.hot_day'].state\nconst heatWarning = states[\"binary_sensor.heat_warning\"].state\nconst showerCooldown = states[\"timer.shower_mode_cooldown\"].state\nconst earlyNight = states[\"binary_sensor.early_night_mode\"].state\n\n// define variables\n\nlet setTemp = []\nlet setEco = []\nlet setHvac = []\nlet setFan = []\nlet setBool = []\n\n// decision logic\n\nif (time === 'day') {\n if (type === 'auto') {\n setBool = 'off'\n }\n if (earlyNight === 'off') {\n setFan = \"off\"\n if (ac === 'on') {\n if (hotDay === 'on' || heatWarning === 'on') {\n setTemp = dayTemp\n setEco = \"eco\"\n setHvac = \"cool\"\n } else {\n setTemp = nightTemp\n setEco = \"eco\"\n setHvac = \"off\"\n }\n }\n } else if (earlyNight === 'on') {\n setTemp = nightTemp\n if (fanMode === 'Fan') {\n setFan = 'on'\n } else {\n setFan = 'off'\n }\n if (acMode === 'AC') {\n setHvac = 'cool'\n } else if (acMode === 'fan') {\n setHvac = 'fan_only'\n } else {\n setHvac = 'off'\n }\n if (hotDay === 'on') {\n setEco = 'off'\n } else {\n setEco = 'on'\n }\n }\n} else if (time === 'night') {\n if (type === 'auto') {\n setBool = 'on'\n }\n if (ac === 'on') {\n setTemp = nightTemp\n if (acMode === 'AC') {\n setEco = 'eco'\n setHvac = 'cool'\n if (hotDay === 'on' || sleeping === 'on') {\n setEco = 'none'\n }\n } else if (acMode === 'Fan') {\n setHvac = 'fan_only'\n } else {\n setHvac = 'off'\n }\n }\n if (fanMode === 'Fan') {\n setFan = 'on'\n } else {\n setFan = 'off'\n }\n} else if (time === 'bedtime') {\n if (ac === 'on') {\n setTemp = bedTemp\n setEco = 'none'\n if (acMode === 'AC') {\n setHvac = 'cool'\n } else if (acMode === 'Fan') {\n setHvac = \"fan_only\"\n }\n }\n if (fanMode === 'Fan') {\n setFan = 'on'\n } else {\n setFan = 'off'\n }\n}\n\nlet sendFan = {\n \"fan\": setFan\n}\n\nlet sendBool = {\n \"bool\": setBool\n}\n\nlet notify = {\n \"topic\": topic,\n \"nighttemp\": nightTemp,\n \"acmode\": acMode,\n \"fanmode\": fanMode\n}\n\nlet sendHvac = {\n \"payload\": {\n \"domain\": \"climate\",\n \"service\": \"set_hvac_mode\",\n \"target\": {\n \"entity_id\": [\"climate.master_bedroom_aircon\"]\n },\n \"data\": {\n \"hvac_mode\": setHvac\n }\n }\n}\n\nlet sendTemp = {\n \"payload\": {\n \"domain\": \"climate\",\n \"service\": \"set_temperature\",\n \"target\": {\n \"entity_id\": [\"climate.master_bedroom_aircon\"]\n },\n \"data\": {\n \"temperature\": setTemp\n }\n }\n}\n\nlet sendEco = {\n \"payload\": {\n \"domain\": \"climate\",\n \"service\": \"set_preset_mode\",\n \"target\": {\n \"entity_id\": [\"climate.master_bedroom_aircon\"]\n },\n \"data\": {\n \"preset_mode\": setEco\n }\n }\n}\n\nlet sendAcFan = {\n \"payload\": {\n \"domain\": \"climate\",\n \"service\": \"set_fan_mode\",\n \"target\": {\n \"entity_id\": [\"climate.master_bedroom_aircon\"]\n },\n \"data\": {\n \"fan_mode\": \"Auto\"\n }\n }\n}\n\nif (type === 'auto') {\n node.send([null, null, sendBool])\n}\n\nif ((type === 'auto' && allowed === 'on') || type === 'manual') {\n if (sleeping === 'on' && type === 'auto') {\n node.status({ fill: \"red\", shape: \"ring\", text: \"Blocked (sleep mode)\" })\n } else if (vacation === 'off') {\n if (topic === 'mrbedroom-cooling' && ac === 'on') {\n node.status({ fill: \"green\", shape: \"dot\", text: \"Cooling Schedule\" })\n node.send([[sendHvac, sendTemp, sendEco, sendAcFan], null, null]);\n } else if (time === 'bedtime') {\n node.status({fill:\"green\",shape:\"dot\",text:\"Bedtime\"})\n node.send([[sendHvac,sendTemp,sendEco,sendAcFan],sendFan,null]);\n } else if (topic === 'manual-night') {\n if (fanMode === 'Fan') {\n node.status({ fill: \"blue\", shape: \"dot\", text: \"Manual Night (Fan)\" })\n node.send([null, sendFan, null])\n } else {\n node.status({ fill: \"blue\", shape: \"dot\", text: \"Manual Night (No Fan)\" })\n node.send([null, sendFan, null])\n }\n } else if (topic === 'mrbedroom-fan' && fanMode == 'Fan') {\n node.status({ fill: \"green\", shape: \"dot\", text: \"Fan Schedule\" })\n node.send([null, sendFan, null])\n } else if (topic === 'mrbedroom-wakeup') {\n node.status({ fill: \"green\", shape: \"dot\", text: \"Wakeup Schedule\" })\n node.send([[sendHvac, sendTemp, sendEco, sendAcFan], sendFan, null])\n } else if (topic === 'manual-day') {\n node.status({ fill: \"blue\", shape: \"dot\", text: \"Manual Day\" })\n node.send([[sendHvac, sendTemp, sendEco, sendAcFan], sendFan, null])\n }\n }\n} else {\n node.status({ fill: \"red\", shape: \"ring\", text: \"Automation Disabled\" })\n}\n", "outputs": 4, "noerr": 0, "initialize": "", @@ -17667,7 +17466,7 @@ "y": 320, "wires": [ [ - "fd0a309681a536de" + "cbe37fd5b5fc4381" ], [ "bf1b0d6542ef6b38" @@ -17699,15 +17498,11 @@ "initialize": "", "finalize": "", "libs": [], - "x": 340, - "y": 80, + "x": 500, + "y": 60, "wires": [ - [ - "9179e99207e9f8f3" - ], - [ - "404c42d6fea46839" - ] + [], + [] ], "outputLabels": [ "Auto", @@ -17735,36 +17530,6 @@ ] ] }, - { - "id": "6ed7feb3956038ed", - "type": "api-call-service", - "z": "72f99805df043603", - "g": "e065b1ed4938b477", - "name": "Eco Off", - "server": "9e87348d.9c1c48", - "version": 5, - "debugenabled": false, - "domain": "climate", - "service": "set_preset_mode", - "areaId": [], - "deviceId": [], - "entityId": [ - "climate.master_bedroom_aircon" - ], - "data": "{\t \"preset_mode\":\"none\"\t}", - "dataType": "jsonata", - "mergeContext": "", - "mustacheAltTags": false, - "outputProperties": [], - "queue": "none", - "x": 880, - "y": 60, - "wires": [ - [ - "67509a5554fc091f" - ] - ] - }, { "id": "9c01880c6319d29b", "type": "function", @@ -18472,6 +18237,32 @@ [] ] }, + { + "id": "cbe37fd5b5fc4381", + "type": "api-call-service", + "z": "72f99805df043603", + "g": "e065b1ed4938b477", + "name": "AC Settings", + "server": "9e87348d.9c1c48", + "version": 5, + "debugenabled": false, + "domain": "", + "service": "", + "areaId": [], + "deviceId": [], + "entityId": [], + "data": "", + "dataType": "json", + "mergeContext": "", + "mustacheAltTags": false, + "outputProperties": [], + "queue": "none", + "x": 750, + "y": 260, + "wires": [ + [] + ] + }, { "id": "9256f78107619596", "type": "ha-time", @@ -19639,6 +19430,18 @@ "propertyType": "msg", "value": "mrbedroom-bedtime", "valueType": "str" + }, + { + "property": "time", + "propertyType": "msg", + "value": "bedtime", + "valueType": "str" + }, + { + "property": "type", + "propertyType": "msg", + "value": "auto", + "valueType": "str" } ], "x": 100,