Kaynağa Gözat

Beca thermostat: split into C and F variants.

The device is switchable between C and F, but the local protocol does
not return any info about which units are in use.  Require the user to
select the correct config.
Added ability to set the units in config by putting a unit attribute on
the temperature dps, use it in the new configs.
Jason Rumney 4 yıl önce
ebeveyn
işleme
5f17af9485

+ 0 - 60
custom_components/tuya_local/devices/beca_bhp6000_thermostat.yaml

@@ -1,60 +0,0 @@
-name: Beca BHP-6000 Thermostat
-primary_entity:
-  entity: climate
-  dps:
-    - id: 1
-      name: hvac_mode
-      type: boolean
-      mapping:
-        - dps_val: false
-          value: "off"
-        - dps_val: true
-          value: "heat_cool"
-    - id: 2
-      name: temperature
-      type: integer
-      constraint: temperature_unit
-      conditions:
-        - dps_val: 1
-          range:
-            min: 5
-            max: 35
-        - dps_val: 2
-          range:
-            min: 5
-            max: 35
-        - dps_val: 3
-          range:
-            min: 40
-            max: 95
-    - id: 3
-      name: current_temperature
-      type: integer
-    - id: 4
-      name: level
-      type: integer
-    - id: 5
-      name: temperature_unit
-      type: integer
-      mapping:
-        - dps_val: 1
-          value: C
-        - dps_val: 2
-          value: C
-        - dps_val: 3
-          value: F
-    - id: 6
-      name: preset_mode
-      type: boolean
-      mapping:
-        - dps_val: false
-          value: normal
-        - dps_val: true
-          value: eco
-secondary_entities:
-  - entity: lock
-    name: Child Lock
-    dps:
-      - id: 7
-        name: lock
-        type: boolean

+ 66 - 0
custom_components/tuya_local/devices/beca_bhp6000_thermostat_c.yaml

@@ -0,0 +1,66 @@
+name: Beca BHP-6000 Thermostat
+primary_entity:
+  entity: climate
+  dps:
+    - id: 2
+      name: temperature
+      type: integer
+      unit: C
+      range:
+        min: 5
+        max: 35
+    - id: 3
+      name: current_temperature
+      type: integer
+    - id: 4
+      name: preset_mode
+      type: integer
+      mapping:
+        - dps_val: 1
+          value: Schedule
+        - dps_val: 2
+          value: Temporary Hold
+        - dps_val: 3
+          value: Permanent Hold
+        - dps_val: 4
+          value: Holiday Hold
+    - id: 5
+      name: hvac_mode
+      type: integer
+      mapping:
+        - dps_val: 1
+          value: cool
+        - dps_val: 2
+          value: heat
+        - dps_val: 3
+          value: "off"
+        - dps_val: 4
+          value: heat_cool
+        - dps_val: 5
+          value: auto
+    - id: 6
+      name: fan_mode
+      type: boolean
+      mapping:
+        - dps_val: false
+          value: auto
+        - dps_val: true
+          value: "on"
+secondary_entities:
+  - entity: lock
+    name: Child Lock
+    dps:
+      - id: 7
+        name: lock
+        type: boolean
+  - entity: light
+    name: Display
+    dps:
+      - id: 1
+        name: switch
+        type: boolean
+        mapping:
+          - dps_val: true
+            icon: "mdi:led-on"
+          - dps_val: false
+            icon: "ldi:led-off"

+ 67 - 0
custom_components/tuya_local/devices/beca_bhp6000_thermostat_f.yaml

@@ -0,0 +1,67 @@
+name: Beca BHP-6000 Thermostat
+legacy_type: beca_bhp6000_thermostat
+primary_entity:
+  entity: climate
+  dps:
+    - id: 2
+      name: temperature
+      type: integer
+      unit: F
+      range:
+        min: 40
+        max: 95
+    - id: 3
+      name: current_temperature
+      type: integer
+    - id: 4
+      name: preset_mode
+      type: integer
+      mapping:
+        - dps_val: 1
+          value: Schedule
+        - dps_val: 2
+          value: Temporary Hold
+        - dps_val: 3
+          value: Permanent Hold
+        - dps_val: 4
+          value: Holiday Hold
+    - id: 5
+      name: hvac_mode
+      type: integer
+      mapping:
+        - dps_val: 1
+          value: cool
+        - dps_val: 2
+          value: heat
+        - dps_val: 3
+          value: "off"
+        - dps_val: 4
+          value: heat_cool
+        - dps_val: 5
+          value: auto
+    - id: 6
+      name: fan_mode
+      type: boolean
+      mapping:
+        - dps_val: false
+          value: auto
+        - dps_val: true
+          value: "on"
+secondary_entities:
+  - entity: lock
+    name: Child Lock
+    dps:
+      - id: 7
+        name: lock
+        type: boolean
+  - entity: light
+    name: Display
+    dps:
+      - id: 1
+        name: switch
+        type: boolean
+        mapping:
+          - dps_val: true
+            icon: "mdi:led-on"
+          - dps_val: false
+            icon: "ldi:led-off"

+ 12 - 0
custom_components/tuya_local/generic/climate.py

@@ -128,6 +128,7 @@ class TuyaLocalClimate(ClimateEntity):
     @property
     def temperature_unit(self):
         """Return the unit of measurement."""
+        # If there is a separate DPS that returns the units, use that
         if self._unit_dps is not None:
             unit = self._unit_dps.get_value(self._device)
             # Only return valid units
@@ -137,6 +138,17 @@ class TuyaLocalClimate(ClimateEntity):
                 return TEMP_FAHRENHEIT
             elif unit == "K":
                 return TEMP_KELVIN
+        # If there unit attribute configured in the temperature dps, use that
+        if self._temperature_dps:
+            unit = self._temperature_dps.unit
+            # Only return valid units
+            if unit == "C":
+                return TEMP_CELSIUS
+            elif unit == "F":
+                return TEMP_FAHRENHEIT
+            elif unit == "K":
+                return TEMP_KELVIN
+        # Return the default unit from the device
         return self._device.temperature_unit
 
     @property

+ 4 - 0
custom_components/tuya_local/helpers/device_config.py

@@ -336,6 +336,10 @@ class TuyaDpsConfig:
     def hidden(self):
         return self._config.get("hidden", False)
 
+    @property
+    def unit(self):
+        return self._config.get("unit")
+
     def _find_map_for_dps(self, value):
         default = None
         for m in self._config.get("mapping", {}):