From b84c53941a05136ea1041784110f95ed48829855 Mon Sep 17 00:00:00 2001 From: Nick Borgers Date: Tue, 7 May 2024 16:44:17 -0400 Subject: [PATCH] Turn up fans - we are not used to heat --- flows.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flows.json b/flows.json index e6accba..837d164 100644 --- a/flows.json +++ b/flows.json @@ -14116,8 +14116,9 @@ "type": "function", "z": "6a064f420a191bf8", "name": "Set fan speeds", - "func": "var currentAirCondition = msg.payload\n\nfunction determineFanSpeedByHeatIndex(airConditionData) {\n // Totally arbitrary formula reflecting our comfort.\n var rawFanSpeed = Math.sqrt((airConditionData[\"heat index\"] - 67) * 4)\n if (isNaN(rawFanSpeed)) {\n rawFanSpeed = 2\n }\n node.debug(\"Heat index indicates a fan speed of \" + rawFanSpeed)\n var actualFanSpeed = Math.max(2, rawFanSpeed) // Min fan speed of 2 when we're here\n var actualFanSpeed = Math.min(10, actualFanSpeed) // Max possible fan speed of 10\n node.debug(\"Capped to \" + actualFanSpeed)\n var fanSpeedAsPercentage = Math.round(actualFanSpeed) * 10\n airConditionData[\"considered fan speeds\"][\"heat index\"] = fanSpeedAsPercentage\n}\n\nfunction determineFanSpeedByFormaldehyde(airConditionData) {\n // I have no idea how to interpret the Formaldehyde/HCHO data right now\n var rawFanSpeed = 2\n if (isNaN(rawFanSpeed)) {\n rawFanSpeed = 2\n }\n node.debug(\"Formaldehyde indicates a fan speed of \" + rawFanSpeed)\n var actualFanSpeed = Math.max(2, rawFanSpeed) // Min fan speed of 2 when we're here\n var actualFanSpeed = Math.min(10, actualFanSpeed) // Max possible fan speed of 10\n node.debug(\"Capped to \" + actualFanSpeed)\n var fanSpeedAsPercentage = Math.round(actualFanSpeed) * 10\n airConditionData[\"considered fan speeds\"][\"formaldehyde\"] = fanSpeedAsPercentage\n}\n\nfunction determineFanSpeedByPM25(airConditionData) {\n // Using guidance found in Dyson app\n var rawFanSpeed = airConditionData[\"pm2.5\"]/10\n if (isNaN(rawFanSpeed)) {\n rawFanSpeed = 2\n }\n node.debug(\"pm2.5 indicates a fan speed of \" + rawFanSpeed)\n var actualFanSpeed = Math.max(2, rawFanSpeed) // Min fan speed of 2 when we're here\n var actualFanSpeed = Math.min(10, actualFanSpeed) // Max possible fan speed of 10\n node.debug(\"Capped to \" + actualFanSpeed)\n var fanSpeedAsPercentage = Math.round(actualFanSpeed) * 10\n airConditionData[\"considered fan speeds\"][\"pm2.5\"] = fanSpeedAsPercentage\n}\n\nfunction determineFanSpeedByVOC(airConditionData) {\n // Using guidance found in Dyson app\n var rawFanSpeed = airConditionData[\"voc\"]/2\n if (isNaN(rawFanSpeed)) {\n rawFanSpeed = 2\n }\n node.debug(\"VOC indicates a fan speed of \" + rawFanSpeed)\n var actualFanSpeed = Math.max(2, rawFanSpeed) // Min fan speed of 2 when we're here\n var actualFanSpeed = Math.min(10, actualFanSpeed) // Max possible fan speed of 10\n node.debug(\"Capped to \" + actualFanSpeed)\n var fanSpeedAsPercentage = Math.round(actualFanSpeed) * 10\n airConditionData[\"considered fan speeds\"][\"voc\"] = fanSpeedAsPercentage\n}\n\nfunction determineFanSpeedByPollutants(airConditionData) {\n determineFanSpeedByFormaldehyde(airConditionData)\n determineFanSpeedByPM25(airConditionData)\n determineFanSpeedByVOC(airConditionData)\n}\n\nfunction determineFanSpeedByHumidifier(airConditionData) {\n if (airConditionData.hasOwnProperty(\"humidity control\")) {\n \n var desired_humidity = airConditionData[\"humidity control\"][\"desired humidity\"]\n var current_humidity = airConditionData[\"humidity\"]\n\n var rawFanSpeed = 2\n\n if (airConditionData[\"humidity control\"][\"humidifier on\"]) {\n rawFanSpeed = desired_humidity - current_humidity\n node.debug(\"Humidifier indicates a fan speed of \" + rawFanSpeed)\n }\n\n if (isNaN(rawFanSpeed)) {\n rawFanSpeed = 2\n }\n var actualFanSpeed = Math.max(2, rawFanSpeed) // Min fan speed of 2 when we're here\n var actualFanSpeed = Math.min(10, actualFanSpeed) // Max possible fan speed of 10\n node.debug(\"Capped to \" + actualFanSpeed)\n var fanSpeedAsPercentage = Math.round(actualFanSpeed) * 10\n airConditionData[\"considered fan speeds\"][\"humidifier\"] = fanSpeedAsPercentage\n }\n}\n\nfunction determineFanSpeed(airConditionData) {\n airConditionData[\"considered fan speeds\"] = {}\n\n determineFanSpeedByHeatIndex(airConditionData)\n determineFanSpeedByPollutants(airConditionData)\n determineFanSpeedByHumidifier(airConditionData)\n\n var actualFanSpeed = Math.max(...Object.values(airConditionData[\"considered fan speeds\"]))\n\n node.debug(\"Decided on fan speed of \" + actualFanSpeed + \"%\")\n\n airConditionData[\"fan speed\"] = actualFanSpeed\n}\n\n// Handle Master Bedroom\nconsole.debug(\"Determining fan speed for Master Bedroom\")\ndetermineFanSpeed(currentAirCondition[\"Master Bedroom\"])\nconsole.debug(\"Determined fan speed for Master Bedroom\")\n\n// Handle Guest Suite\nconsole.debug(\"Determining fan speed for Guest Bedroom\")\ndetermineFanSpeed(currentAirCondition[\"Bedroom\"])\nconsole.debug(\"Determined fan speed for Guest Bedroom\")\n\n// Handle Living Room\nconsole.debug(\"Determining fan speed for Living Room\")\ndetermineFanSpeed(currentAirCondition[\"Living Room Center\"])\nconsole.debug(\"Determined fan speed for Living Room\")\n\nreturn msg;\n", + "func": "var currentAirCondition = msg.payload\n\nfunction determineFanSpeedByHeatIndex(airConditionData) {\n // Totally arbitrary formula reflecting our comfort.\n var rawFanSpeed = Math.sqrt((airConditionData[\"heat index\"] - 67) * 6)\n if (isNaN(rawFanSpeed)) {\n rawFanSpeed = 2\n }\n node.debug(\"Heat index indicates a fan speed of \" + rawFanSpeed)\n var actualFanSpeed = Math.max(2, rawFanSpeed) // Min fan speed of 2 when we're here\n var actualFanSpeed = Math.min(10, actualFanSpeed) // Max possible fan speed of 10\n node.debug(\"Capped to \" + actualFanSpeed)\n var fanSpeedAsPercentage = Math.round(actualFanSpeed) * 10\n airConditionData[\"considered fan speeds\"][\"heat index\"] = fanSpeedAsPercentage\n}\n\nfunction determineFanSpeedByFormaldehyde(airConditionData) {\n // I have no idea how to interpret the Formaldehyde/HCHO data right now\n var rawFanSpeed = 2\n if (isNaN(rawFanSpeed)) {\n rawFanSpeed = 2\n }\n node.debug(\"Formaldehyde indicates a fan speed of \" + rawFanSpeed)\n var actualFanSpeed = Math.max(2, rawFanSpeed) // Min fan speed of 2 when we're here\n var actualFanSpeed = Math.min(10, actualFanSpeed) // Max possible fan speed of 10\n node.debug(\"Capped to \" + actualFanSpeed)\n var fanSpeedAsPercentage = Math.round(actualFanSpeed) * 10\n airConditionData[\"considered fan speeds\"][\"formaldehyde\"] = fanSpeedAsPercentage\n}\n\nfunction determineFanSpeedByPM25(airConditionData) {\n // Using guidance found in Dyson app\n var rawFanSpeed = airConditionData[\"pm2.5\"]/10\n if (isNaN(rawFanSpeed)) {\n rawFanSpeed = 2\n }\n node.debug(\"pm2.5 indicates a fan speed of \" + rawFanSpeed)\n var actualFanSpeed = Math.max(2, rawFanSpeed) // Min fan speed of 2 when we're here\n var actualFanSpeed = Math.min(10, actualFanSpeed) // Max possible fan speed of 10\n node.debug(\"Capped to \" + actualFanSpeed)\n var fanSpeedAsPercentage = Math.round(actualFanSpeed) * 10\n airConditionData[\"considered fan speeds\"][\"pm2.5\"] = fanSpeedAsPercentage\n}\n\nfunction determineFanSpeedByVOC(airConditionData) {\n // Using guidance found in Dyson app\n var rawFanSpeed = airConditionData[\"voc\"]/2\n if (isNaN(rawFanSpeed)) {\n rawFanSpeed = 2\n }\n node.debug(\"VOC indicates a fan speed of \" + rawFanSpeed)\n var actualFanSpeed = Math.max(2, rawFanSpeed) // Min fan speed of 2 when we're here\n var actualFanSpeed = Math.min(10, actualFanSpeed) // Max possible fan speed of 10\n node.debug(\"Capped to \" + actualFanSpeed)\n var fanSpeedAsPercentage = Math.round(actualFanSpeed) * 10\n airConditionData[\"considered fan speeds\"][\"voc\"] = fanSpeedAsPercentage\n}\n\nfunction determineFanSpeedByPollutants(airConditionData) {\n determineFanSpeedByFormaldehyde(airConditionData)\n determineFanSpeedByPM25(airConditionData)\n determineFanSpeedByVOC(airConditionData)\n}\n\nfunction determineFanSpeedByHumidifier(airConditionData) {\n if (airConditionData.hasOwnProperty(\"humidity control\")) {\n \n var desired_humidity = airConditionData[\"humidity control\"][\"desired humidity\"]\n var current_humidity = airConditionData[\"humidity\"]\n\n var rawFanSpeed = 2\n\n if (airConditionData[\"humidity control\"][\"humidifier on\"]) {\n rawFanSpeed = desired_humidity - current_humidity\n node.debug(\"Humidifier indicates a fan speed of \" + rawFanSpeed)\n }\n\n if (isNaN(rawFanSpeed)) {\n rawFanSpeed = 2\n }\n var actualFanSpeed = Math.max(2, rawFanSpeed) // Min fan speed of 2 when we're here\n var actualFanSpeed = Math.min(10, actualFanSpeed) // Max possible fan speed of 10\n node.debug(\"Capped to \" + actualFanSpeed)\n var fanSpeedAsPercentage = Math.round(actualFanSpeed) * 10\n airConditionData[\"considered fan speeds\"][\"humidifier\"] = fanSpeedAsPercentage\n }\n}\n\nfunction determineFanSpeed(airConditionData) {\n airConditionData[\"considered fan speeds\"] = {}\n\n determineFanSpeedByHeatIndex(airConditionData)\n determineFanSpeedByPollutants(airConditionData)\n determineFanSpeedByHumidifier(airConditionData)\n\n var actualFanSpeed = Math.max(...Object.values(airConditionData[\"considered fan speeds\"]))\n\n node.debug(\"Decided on fan speed of \" + actualFanSpeed + \"%\")\n\n airConditionData[\"fan speed\"] = actualFanSpeed\n}\n\n// Handle Master Bedroom\nconsole.debug(\"Determining fan speed for Master Bedroom\")\ndetermineFanSpeed(currentAirCondition[\"Master Bedroom\"])\nconsole.debug(\"Determined fan speed for Master Bedroom\")\n\n// Handle Guest Suite\nconsole.debug(\"Determining fan speed for Guest Bedroom\")\ndetermineFanSpeed(currentAirCondition[\"Bedroom\"])\nconsole.debug(\"Determined fan speed for Guest Bedroom\")\n\n// Handle Living Room\nconsole.debug(\"Determining fan speed for Living Room\")\ndetermineFanSpeed(currentAirCondition[\"Living Room Center\"])\nconsole.debug(\"Determined fan speed for Living Room\")\n\nreturn msg;\n", "outputs": 1, + "timeout": "", "noerr": 0, "initialize": "", "finalize": "",