Explorar o código

WIP: You can only set target humidity in Normal mode

Also added icons for different dehumidifier presets
Nik Rolls %!s(int64=5) %!d(string=hai) anos
pai
achega
092e0f1082

+ 6 - 7
.devcontainer/devcontainer.json

@@ -4,12 +4,7 @@
   "context": "..",
   "appPort": ["8123:8123"],
   "postCreateCommand": "dc install",
-  "runArgs": [
-    "-e",
-    "GIT_EDITOR=code --wait",
-    "-v",
-    "${env:HOME}${env:USERPROFILE}/.ssh:/tmp/.ssh"
-  ],
+  "runArgs": ["-e", "GIT_EDITOR=code --wait"],
   "extensions": [
     "ms-python.python",
     "visualstudioexptteam.vscodeintellicode",
@@ -27,5 +22,9 @@
     "editor.formatOnType": true,
     "files.trimTrailingWhitespace": true,
     "terminal.integrated.shell.linux": "/bin/bash"
-  }
+  },
+  "mounts": [
+    "source=${env:HOME}${env:USERPROFILE}/.ssh,target=/tmp/.ssh,type=bind,consistency=cached",
+    "source=${localWorkspaceFolder}/config,target=/config,type=bind,consistency=cached"
+  ]
 }

+ 1 - 0
.gitignore

@@ -1,3 +1,4 @@
 /.idea/
 /.vscode/
 __pycache__/
+/config/

+ 5 - 0
.vscode/settings.json

@@ -0,0 +1,5 @@
+{
+  "files.exclude": {
+    "config/custom_components/goldair_climate": true
+  }
+}

+ 1 - 1
.vscode/tasks.json

@@ -10,7 +10,7 @@
     {
       "label": "Run Home Assistant on port 8123",
       "type": "shell",
-      "command": "container start",
+      "command": "pkill hass;container start",
       "problemMatcher": []
     },
     {

+ 16 - 3
custom_components/goldair_climate/dehumidifier/climate.py

@@ -9,6 +9,7 @@ from homeassistant.components.climate.const import (
     ATTR_PRESET_MODE,
     FAN_HIGH,
     FAN_LOW,
+    HVAC_MODE_OFF,
     SUPPORT_FAN_MODE,
     SUPPORT_PRESET_MODE,
     SUPPORT_TARGET_HUMIDITY,
@@ -84,6 +85,15 @@ class GoldairDehumidifier(ClimateDevice):
             return "mdi:cup-water"
         elif self.defrosting:
             return "mdi:snowflake-melt"
+        elif (
+            self.hvac_mode is not HVAC_MODE_OFF
+            and self.preset_mode is PRESET_DRY_CLOTHES
+        ):
+            return "mdi:tshirt-crew-outline"
+        elif (
+            self.hvac_mode is not HVAC_MODE_OFF and self.preset_mode is PRESET_AIR_CLEAN
+        ):
+            return "mdi:air-purifier"
         else:
             return "mdi:air-humidifier"
 
@@ -105,13 +115,16 @@ class GoldairDehumidifier(ClimateDevice):
     @property
     def target_humidity(self):
         """Return the current target humidity."""
-        return self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_TARGET_HUMIDITY])
+        if self.preset_mode is PRESET_NORMAL:
+            return self._device.get_property(PROPERTY_TO_DPS_ID[ATTR_TARGET_HUMIDITY])
+        else:
+            return None
 
     async def async_set_humidity(self, humidity):
         """Set the device's target humidity."""
-        if self.preset_mode in [PRESET_AIR_CLEAN, PRESET_DRY_CLOTHES]:
+        if self.preset_mode is not PRESET_NORMAL:
             raise ValueError(
-                "Humidity can only be changed while in Normal, Low or High preset modes."
+                "Target humidity can only be changed while in Normal mode."
             )
         humidity = int(
             self._HUMIDITY_STEP * round(float(humidity) / self._HUMIDITY_STEP)