Просмотр исходного кода

Add support for Minco MH-2318 Thermostats.

Issue #68.

Expanded support for sensors to obtain unit from a unit attribute, instead of hardcoded to a specific value in the config.
Jason Rumney 4 лет назад
Родитель
Сommit
96b8d4894a

+ 1 - 0
ACKNOWLEDGEMENTS.md

@@ -51,3 +51,4 @@ Further device support has been made with the assistance of users.  Please consi
  - [Skro11-ru](https://github.com/Skro11-ru) for assistance in supporting Moes BHT-002 variant without external temperature sensor.
  - [novisys](https://github.com/novisys) for clarifications about BHT-6000 thermostat functionality.
  - [nzcodarnoc](https://github.com/nzcodarnoc) for contributing support for Kogan KASHMFP heaters.
+ - [pascaltippelt](https://github.com/pascaltippelt) for assistance in supporting Minco MH-1823 thermostat.

+ 1 - 0
README.md

@@ -72,6 +72,7 @@ the device will not work despite being listed below.
 - Awow/Mi-heat TH213 thermostat
 - Siswell T29UTW thermostat
 - Siswell C16 thermostat (rebadged as Warmme, Klima and others)
+- Minco MH-1823D thermostat
 
 ### Kettles
 - Kogan Glass 1.7L Smart Kettle (not reliably detected)

+ 8 - 2
custom_components/tuya_local/generic/sensor.py

@@ -20,9 +20,11 @@ class TuyaLocalSensor(TuyaLocalEntity, SensorEntity):
             config (TuyaEntityConfig): the configuration for this entity
         """
         dps_map = self._init_begin(device, config)
-        self._sensor_dps = dps_map.pop("sensor")
+        self._sensor_dps = dps_map.pop("sensor", None)
         if self._sensor_dps is None:
             raise AttributeError(f"{config.name} is missing a sensor dps")
+        self._unit_dps = dps_map.pop("unit", None)
+
         self._init_end(dps_map)
 
     @property
@@ -51,7 +53,11 @@ class TuyaLocalSensor(TuyaLocalEntity, SensorEntity):
     @property
     def native_unit_of_measurement(self):
         """Return the unit for the sensor"""
-        unit = self._sensor_dps.unit
+        if self._unit_dps is None:
+            unit = self._sensor_dps.unit
+        else:
+            unit = self._unit_dps.get_value(self._device)
+
         # Temperatures use Unicode characters, translate from simpler ASCII
         if unit == "C":
             unit = TEMP_CELSIUS

+ 1 - 1
custom_components/tuya_local/manifest.json

@@ -2,7 +2,7 @@
     "domain": "tuya_local",
     "iot_class": "local_polling",
     "name": "Tuya Local",
-    "version": "0.13.0",
+    "version": "0.13.1",
     "documentation": "https://github.com/make-all/tuya-local",
     "issue_tracker": "https://github.com/make-all/tuya-local/issues",
     "dependencies": [],

+ 26 - 0
tests/const.py

@@ -570,3 +570,29 @@ QOTO_SPRINKLER_PAYLOAD = {
     "105": 10800,
     "108": 0,
 }
+
+MINCO_MH1823D_THERMOSTAT_PAYLOAD = {
+    "1": True,
+    "2": "program",
+    "3": "stop",
+    "5": False,
+    "9": True,
+    "12": False,
+    "18": "out",
+    "19": "c",
+    "22": 18,
+    "23": 64,
+    "32": 1,
+    "33": 205,
+    "35": 0,
+    "37": 689,
+    "39": "7",
+    "45": 0,
+    "101": 200,
+    "102": 680,
+    "103": 0,
+    "104": 2,
+    "105": "no_power",
+    "106": 35,
+    "107": 95,
+}