Shower mode nodes rewritten to handle rate-limiting

home_automation/Home-Assistant-Configs#237
This commit is contained in:
2025-04-23 21:53:27 -04:00
parent 74f7bbb240
commit d91812a27c

View File

@ -937,9 +937,6 @@
"bc592ba259667f9d", "bc592ba259667f9d",
"1f7ac875e593d434", "1f7ac875e593d434",
"7a7f626dce181b23", "7a7f626dce181b23",
"f541ad53e32f703b",
"66e85878d60c7d65",
"bcba065aa5ecb2be",
"6c06c2eec1583c66", "6c06c2eec1583c66",
"e2581a5f3f4888df", "e2581a5f3f4888df",
"1dfb0bcc98f1457b", "1dfb0bcc98f1457b",
@ -952,9 +949,6 @@
"94c022d2eb71e7d5", "94c022d2eb71e7d5",
"ce5d8005cbf08144", "ce5d8005cbf08144",
"7646c6833d5a1df2", "7646c6833d5a1df2",
"01c0448b4889d754",
"17b6f73d75f480fd",
"7852593ec89f150a",
"8286284fc9598efa", "8286284fc9598efa",
"cbe37fd5b5fc4381", "cbe37fd5b5fc4381",
"5def5d2440e767b3", "5def5d2440e767b3",
@ -981,7 +975,9 @@
"ffa5d38853e1360a", "ffa5d38853e1360a",
"5cce5b011ebc5d32", "5cce5b011ebc5d32",
"6f4235c9d4f6a6ea", "6f4235c9d4f6a6ea",
"862666f576addab8" "862666f576addab8",
"bcef7debc9bda36c",
"5ee549aa5e97d4a5"
], ],
"x": 14, "x": 14,
"y": 11.5, "y": 11.5,
@ -2434,7 +2430,8 @@
"71b1c6e934b85637", "71b1c6e934b85637",
"334a79e6f5f3a16a", "334a79e6f5f3a16a",
"2718f2695ff412fa", "2718f2695ff412fa",
"7d50b11bbf5de8fd" "7d50b11bbf5de8fd",
"53b440a31d30df1b"
], ],
"x": 14, "x": 14,
"y": 1319, "y": 1319,
@ -21612,106 +21609,6 @@
] ]
] ]
}, },
{
"id": "f541ad53e32f703b",
"type": "api-call-service",
"z": "72f99805df043603",
"g": "e065b1ed4938b477",
"name": "Set to Dry",
"server": "9e87348d.9c1c48",
"version": 7,
"debugenabled": false,
"action": "climate.set_hvac_mode",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"climate.master_bedroom_aircon"
],
"labelId": [],
"data": "{\t \"hvac_mode\":\"dry\"\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": false,
"domain": "climate",
"service": "set_hvac_mode",
"x": 540,
"y": 620,
"wires": [
[
"66e85878d60c7d65"
]
]
},
{
"id": "66e85878d60c7d65",
"type": "api-call-service",
"z": "72f99805df043603",
"g": "e065b1ed4938b477",
"name": "Eco Off",
"server": "9e87348d.9c1c48",
"version": 7,
"debugenabled": false,
"action": "climate.set_preset_mode",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"climate.master_bedroom_aircon"
],
"labelId": [],
"data": "{\t \"preset_mode\":\"none\"\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": false,
"domain": "climate",
"service": "set_preset_mode",
"x": 700,
"y": 620,
"wires": [
[
"bcba065aa5ecb2be"
]
]
},
{
"id": "bcba065aa5ecb2be",
"type": "api-call-service",
"z": "72f99805df043603",
"g": "e065b1ed4938b477",
"name": "Set Temp",
"server": "9e87348d.9c1c48",
"version": 7,
"debugenabled": false,
"action": "climate.set_temperature",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"climate.master_bedroom_aircon"
],
"labelId": [],
"data": "{\t \"temperature\": set\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": false,
"domain": "climate",
"service": "set_temperature",
"x": 860,
"y": 620,
"wires": [
[]
]
},
{ {
"id": "6c06c2eec1583c66", "id": "6c06c2eec1583c66",
"type": "comment", "type": "comment",
@ -22091,7 +21988,7 @@
"z": "72f99805df043603", "z": "72f99805df043603",
"g": "e065b1ed4938b477", "g": "e065b1ed4938b477",
"name": "On", "name": "On",
"func": "const states = global.get('homeassistant.homeAssistant.states')\nconst ac = global.get('masterBedroom.aircon.installed', \"diskCon\")\nconst temp = global.get('outdoorTemp.tempStr')\nconst threshold = states['input_number.master_bedroom_aircon_run_threshold'].state\nconst nightTemp = states['input_number.master_bedroom_night_temp'].state\nconst bedTemp = states['input_number.master_bedroom_bedtime_temp'].state\nconst sleeping = states['input_boolean.master_bedroom_sleeping'].state\n\nif (ac === 'on') {\n if (temp >= threshold) {\n if (sleeping === 'on') {\n msg.set = bedTemp\n node.status({fill:\"green\",shape:\"dot\",text:`Shower Mode On: ${bedTemp}`})\n return msg\n } else {\n msg.set = nightTemp\n node.status({fill:\"green\",shape:\"dot\",text:`Shower Mode On: ${nightTemp}`})\n return msg\n }\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Too Cold\"})\n return null\n }\n} else {\n node.status({fill:\"red\",shape:\"ring\",text:\"A/C Not Installed\"})\n return null\n}\n", "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst ac = global.get('masterBedroom.aircon.installed', \"diskCon\")\nconst temp = global.get('outdoorTemp.tempStr')\nconst threshold = states['input_number.master_bedroom_aircon_run_threshold'].state\nconst nightTemp = states['input_number.master_bedroom_night_temp'].state\nconst bedTemp = states['input_number.master_bedroom_bedtime_temp'].state\nconst sleeping = states['input_boolean.master_bedroom_sleeping'].state\n\nconst masterBedroomAircon = [\"climate.master_bedroom_aircon\"]\n\nlet setTemp = []\nlet setHvac = \"dry\"\nlet setEco = \"turn_off\"\n\nif (sleeping === 'on') {\n setTemp = bedTemp\n} else {\n setTemp = nightTemp\n}\n\nlet sendHvac = {\n \"payload\": {\n \"action\": \"climate.set_hvac_mode\",\n \"target\": {\n \"entity_id\": masterBedroomAircon\n },\n \"data\": {\n \"hvac_mode\": setHvac\n }\n }\n}\n\nlet sendTemp = {\n \"payload\": {\n \"action\": \"climate.set_temperature\",\n \"target\": {\n \"entity_id\": masterBedroomAircon\n },\n \"data\": {\n \"temperature\": setTemp\n }\n }\n}\n\nlet sendEco = {\n \"payload\": {\n \"action\": `switch.${setEco}`,\n \"target\": {\n \"entity_id\": [\"switch.master_bedroom_aircon_eco_mode\"]\n },\n \"data\": {}\n }\n}\n\nif (ac === 'on') {\n if (temp >= threshold) {\n node.status({fill:\"green\",shape:\"dot\",text:`Shower Mode On: ${setTemp}°F`})\n node.send([[sendHvac, sendTemp, sendEco]])\n } else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Too Cold\"})\n return null\n }\n} else {\n node.status({fill:\"red\",shape:\"ring\",text:\"A/C Not Installed\"})\n return null\n}\n",
"outputs": 1, "outputs": 1,
"timeout": "", "timeout": "",
"noerr": 0, "noerr": 0,
@ -22102,8 +21999,8 @@
"y": 620, "y": 620,
"wires": [ "wires": [
[ [
"f541ad53e32f703b", "002858f9b16ed975",
"002858f9b16ed975" "5ee549aa5e97d4a5"
] ]
], ],
"icon": "node-red/switch.svg" "icon": "node-red/switch.svg"
@ -22491,7 +22388,7 @@
"z": "72f99805df043603", "z": "72f99805df043603",
"g": "e065b1ed4938b477", "g": "e065b1ed4938b477",
"name": "Off", "name": "Off",
"func": "const states = global.get('homeassistant.homeAssistant.states')\nconst ac = global.get('masterBedroom.aircon.installed', \"diskCon\")\nconst temp = global.get('outdoorTemp.tempStr')\nconst threshold = states['input_number.master_bedroom_aircon_run_threshold'].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 currentSetTemp = states['climate.master_bedroom_aircon'].attributes.temperature\nconst coolingTime = states['input_boolean.master_bedroom_cooling_on'].state\nconst sleeping = states['input_boolean.master_bedroom_sleeping'].state\nconst hotDay = states['input_boolean.hot_day'].state\nconst topic = msg.topic\n\nlet setTemp = {}\nlet ecoMode = {}\nlet duration = {}\nlet end = {}\nlet hvac = {}\n\nif (topic === 'toggle') {\n if (hotDay === 'on' || sleeping === 'on') {\n setTemp = bedTemp\n ecoMode = 'none'\n } else {\n setTemp = nightTemp\n ecoMode = 'eco'\n }\n} else if (topic === 'timer') {\n if (currentSetTemp == bedTemp) {\n setTemp = nightTemp\n if (hotDay === 'on') {\n ecoMode = 'none'\n } else {\n ecoMode = 'eco'\n }\n } else {\n setTemp = dayTemp\n ecoMode = 'eco'\n }\n}\n\nif (setTemp == bedTemp) {\n duration = 3600\n} else if (setTemp == nightTemp && hotDay === 'off') {\n duration = 3600\n} else {\n duration = 1800\n}\n\nif (setTemp == dayTemp) {\n end = true\n if (hotDay === 'off') {\n hvac = 'off'\n } else {\n hvac = 'cool'\n }\n} else if (setTemp != bedTemp && coolingTime === 'on') {\n end = true\n hvac = 'cool'\n} else {\n end = false\n hvac = 'cool'\n}\n\nlet setMsg = {\n \"set\": setTemp,\n \"eco\": ecoMode,\n \"hvac\": hvac,\n \"end\": end\n}\n\nlet timerStart = {\n \"duration\": duration\n}\n\nif (ac === 'on' && temp >= threshold) {\n if (sleeping === 'on' || coolingTime === 'on' || end === true) {\n node.status({fill:\"green\",shape:\"dot\",text:\"Finished\"})\n return [setMsg, null]\n } else {\n node.status({fill:\"blue\",shape:\"dot\",text:\"Next Cycle\"})\n return [setMsg, timerStart]\n }\n} else if (ac === 'off') {\n node.status({fill:\"red\",shape:\"ring\",text:\"A/C Not Installed\"})\n return null\n} else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Too Cold\"})\n return null\n}\n", "func": "const states = global.get('homeassistant.homeAssistant.states')\nconst ac = global.get('masterBedroom.aircon.installed', \"diskCon\")\nconst temp = global.get('outdoorTemp.tempStr')\nconst threshold = states['input_number.master_bedroom_aircon_run_threshold'].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 currentSetTemp = states['climate.master_bedroom_aircon'].attributes.temperature\nconst coolingTime = states['input_boolean.master_bedroom_cooling_on'].state\nconst sleeping = states['input_boolean.master_bedroom_sleeping'].state\nconst hotDay = states['input_boolean.hot_day'].state\nconst topic = msg.topic\n\nconst masterBedroomAircon = [\"climate.master_bedroom_aircon\"]\n\nlet setTemp = {}\nlet setEco = {}\nlet duration = {}\nlet end = {}\nlet setHvac = {}\n\nif (topic === 'toggle') {\n if (hotDay === 'on' || sleeping === 'on') {\n setTemp = bedTemp\n setEco = 'turn_off'\n } else {\n setTemp = nightTemp\n setEco = 'turn_on'\n }\n} else if (topic === 'timer') {\n if (currentSetTemp == bedTemp) {\n setTemp = nightTemp\n if (hotDay === 'on') {\n setEco = 'turn_off'\n } else {\n setEco = 'turn_on'\n }\n } else {\n setTemp = dayTemp\n setEco = 'turn_on'\n }\n}\n\nif (setTemp == bedTemp) {\n duration = 3600\n} else if (setTemp == nightTemp && hotDay === 'off') {\n duration = 3600\n} else {\n duration = 1800\n}\n\nif (setTemp == dayTemp) {\n end = true\n if (hotDay === 'off') {\n setHvac = 'off'\n } else {\n setHvac = 'cool'\n }\n} else if (setTemp != bedTemp && coolingTime === 'on') {\n end = true\n setHvac = 'cool'\n} else {\n end = false\n setHvac = 'cool'\n}\n\nlet timerStart = {\n \"duration\": duration\n}\n\nlet sendHvac = {\n \"payload\": {\n \"action\": \"climate.set_hvac_mode\",\n \"target\": {\n \"entity_id\": masterBedroomAircon\n },\n \"data\": {\n \"hvac_mode\": setHvac\n }\n }\n}\n\nlet sendTemp = {\n \"payload\": {\n \"action\": \"climate.set_temperature\",\n \"target\": {\n \"entity_id\": masterBedroomAircon\n },\n \"data\": {\n \"temperature\": setTemp\n }\n }\n}\n\nlet sendEco = {\n \"payload\": {\n \"action\": `switch.${setEco}`,\n \"target\": {\n \"entity_id\": [\"switch.master_bedroom_aircon_eco_mode\"]\n },\n \"data\": {}\n }\n}\n\nlet sendAcFan = {\n \"payload\": {\n \"action\": \"climate.set_fan_mode\",\n \"target\": {\n \"entity_id\": masterBedroomAircon\n },\n \"data\": {\n \"fan_mode\": \"auto\"\n }\n }\n}\n\nif (ac === 'on' && temp >= threshold) {\n if (sleeping === 'on' || coolingTime === 'on' || end === true) {\n node.status({fill:\"green\",shape:\"dot\",text:\"Finished\"})\n return [[sendHvac, sendTemp, sendAcFan, sendEco], null]\n } else {\n node.status({fill:\"blue\",shape:\"dot\",text:\"Next Cycle\"})\n return [[sendHvac, sendTemp, sendAcFan, sendEco], timerStart]\n }\n} else if (ac === 'off') {\n node.status({fill:\"red\",shape:\"ring\",text:\"A/C Not Installed\"})\n return null\n} else {\n node.status({fill:\"red\",shape:\"ring\",text:\"Too Cold\"})\n return null\n}\n",
"outputs": 2, "outputs": 2,
"timeout": "", "timeout": "",
"noerr": 0, "noerr": 0,
@ -22502,8 +22399,8 @@
"y": 700, "y": 700,
"wires": [ "wires": [
[ [
"01c0448b4889d754", "97f433c699d1f83e",
"97f433c699d1f83e" "5ee549aa5e97d4a5"
], ],
[ [
"8286284fc9598efa", "8286284fc9598efa",
@ -22515,106 +22412,6 @@
"Timer" "Timer"
] ]
}, },
{
"id": "01c0448b4889d754",
"type": "api-call-service",
"z": "72f99805df043603",
"g": "e065b1ed4938b477",
"name": "HVAC",
"server": "9e87348d.9c1c48",
"version": 7,
"debugenabled": false,
"action": "climate.set_hvac_mode",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"climate.master_bedroom_aircon"
],
"labelId": [],
"data": "{\t \"hvac_mode\": hvac\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": false,
"domain": "climate",
"service": "set_hvac_mode",
"x": 530,
"y": 680,
"wires": [
[
"17b6f73d75f480fd"
]
]
},
{
"id": "17b6f73d75f480fd",
"type": "api-call-service",
"z": "72f99805df043603",
"g": "e065b1ed4938b477",
"name": "Eco",
"server": "9e87348d.9c1c48",
"version": 7,
"debugenabled": false,
"action": "climate.set_preset_mode",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"climate.master_bedroom_aircon"
],
"labelId": [],
"data": "{\t \"preset_mode\": eco\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": false,
"domain": "climate",
"service": "set_preset_mode",
"x": 690,
"y": 680,
"wires": [
[
"7852593ec89f150a"
]
]
},
{
"id": "7852593ec89f150a",
"type": "api-call-service",
"z": "72f99805df043603",
"g": "e065b1ed4938b477",
"name": "Set Temp",
"server": "9e87348d.9c1c48",
"version": 7,
"debugenabled": false,
"action": "climate.set_temperature",
"floorId": [],
"areaId": [],
"deviceId": [],
"entityId": [
"climate.master_bedroom_aircon"
],
"labelId": [],
"data": "{\t \"temperature\": set\t}",
"dataType": "jsonata",
"mergeContext": "",
"mustacheAltTags": false,
"outputProperties": [],
"queue": "none",
"blockInputOverrides": false,
"domain": "climate",
"service": "set_temperature",
"x": 860,
"y": 680,
"wires": [
[]
]
},
{ {
"id": "8286284fc9598efa", "id": "8286284fc9598efa",
"type": "api-call-service", "type": "api-call-service",
@ -24189,7 +23986,7 @@
"wires": [ "wires": [
[ [
"7472fd892bcfc621", "7472fd892bcfc621",
"1e2abb7eff658e81" "53b440a31d30df1b"
], ],
[ [
"f5d407ee3f07dee6", "f5d407ee3f07dee6",
@ -24453,7 +24250,7 @@
"y": 1360, "y": 1360,
"wires": [ "wires": [
[ [
"1e2abb7eff658e81" "53b440a31d30df1b"
], ],
[ [
"15b160d6bfe30b15" "15b160d6bfe30b15"
@ -25067,6 +24864,64 @@
], ],
"l": false "l": false
}, },
{
"id": "53b440a31d30df1b",
"type": "delay",
"z": "72f99805df043603",
"g": "5802ea32c1de36e8",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 545,
"y": 1480,
"wires": [
[
"1e2abb7eff658e81"
]
],
"l": false
},
{
"id": "bcef7debc9bda36c",
"type": "link in",
"z": "72f99805df043603",
"g": "e065b1ed4938b477",
"name": "Master Bedroom Aircon Settings - In",
"links": [
"5ee549aa5e97d4a5"
],
"x": 635,
"y": 60,
"wires": [
[
"862666f576addab8"
]
]
},
{
"id": "5ee549aa5e97d4a5",
"type": "link out",
"z": "72f99805df043603",
"g": "e065b1ed4938b477",
"name": "Shower Mode AC Settings",
"mode": "link",
"links": [
"bcef7debc9bda36c"
],
"x": 485,
"y": 660,
"wires": []
},
{ {
"id": "48b8af9419ed18d6", "id": "48b8af9419ed18d6",
"type": "subflow:384eaf2f63dcb5db", "type": "subflow:384eaf2f63dcb5db",