Kaynağa Gözat

Neocool siren: tone off by one, and min/max temp scale off

Siren general issue: volume does not work (needs to be volume_level).
 - fix this by using the ATTR_ constants from HA siren/const.py

Issue #673
Jason Rumney 2 yıl önce
ebeveyn
işleme
f5103908ca

+ 22 - 26
custom_components/tuya_local/devices/neo_coolcam_siren.yaml

@@ -9,41 +9,41 @@ primary_entity:
       type: string
       name: tone
       mapping:
-        - dps_val: "0"
-          value: Doorbell
         - dps_val: "1"
-          value: Für Elise
+          value: Doorbell
         - dps_val: "2"
-          value: Big Ben
+          value: Für Elise
         - dps_val: "3"
-          value: Ring ring
+          value: Big Ben
         - dps_val: "4"
-          value: Lone Ranger
+          value: Ring ring
         - dps_val: "5"
-          value: Turkish march
+          value: Lone Ranger
         - dps_val: "6"
-          value: High pitched
+          value: Turkish march
         - dps_val: "7"
-          value: Red alert
+          value: High pitched
         - dps_val: "8"
-          value: Crickets
+          value: Red alert
         - dps_val: "9"
-          value: Beep
+          value: Crickets
         - dps_val: "10"
-          value: Dog bark
+          value: Beep
         - dps_val: "11"
-          value: Police siren
+          value: Dog bark
         - dps_val: "12"
-          value: Grandfather clock
+          value: Police siren
         - dps_val: "13"
-          value: Phone ring
+          value: Grandfather clock
         - dps_val: "14"
-          value: Fire truck
+          value: Phone ring
         - dps_val: "15"
-          value: Clock chime
+          value: Fire truck
         - dps_val: "16"
-          value: Alarm clock
+          value: Clock chime
         - dps_val: "17"
+          value: Alarm clock
+        - dps_val: "18"
           value: School bell
     - id: 103
       type: integer
@@ -123,10 +123,8 @@ secondary_entities:
         name: value
         unit: C
         range:
-          min: -200
-          max: 500
-        mapping:
-          - scale: 10
+          min: -20
+          max: 50
   - entity: number
     name: High temperature threshold
     category: config
@@ -137,10 +135,8 @@ secondary_entities:
         name: value
         unit: C
         range:
-          min: -200
-          max: 500
-        mapping:
-          - scale: 10
+          min: -20
+          max: 50
   - entity: number
     name: Low humidity threshold
     category: config

+ 11 - 7
custom_components/tuya_local/siren.py

@@ -5,7 +5,11 @@ from homeassistant.components.siren import (
     SirenEntity,
     SirenEntityFeature,
 )
-
+from homeassistant.components.siren.const import (
+    ATTR_DURATION,
+    ATTR_TONE,
+    ATTR_VOLUME_LEVEL,
+)
 from .device import TuyaLocalDevice
 from .helpers.config import async_tuya_setup_platform
 from .helpers.device_config import TuyaEntityConfig
@@ -35,9 +39,9 @@ class TuyaLocalSiren(TuyaLocalEntity, SirenEntity):
         """
         super().__init__()
         dps_map = self._init_begin(device, config)
-        self._tone_dp = dps_map.get("tone", None)
-        self._volume_dp = dps_map.get("volume_level", None)
-        self._duration_dp = dps_map.get("duration", None)
+        self._tone_dp = dps_map.get(ATTR_TONE, None)
+        self._volume_dp = dps_map.get(ATTR_VOLUME_LEVEL, None)
+        self._duration_dp = dps_map.get(ATTR_DURATION, None)
         self._switch_dp = dps_map.get("switch", None)
         self._init_end(dps_map)
         # All control of features is through the turn_on service, so we need to
@@ -69,9 +73,9 @@ class TuyaLocalSiren(TuyaLocalEntity, SirenEntity):
             return self._tone_dp.get_value(self._device) != "off"
 
     async def async_turn_on(self, **kwargs) -> None:
-        tone = kwargs.get("tone", None)
-        duration = kwargs.get("duration", None)
-        volume = kwargs.get("volume", None)
+        tone = kwargs.get(ATTR_TONE, None)
+        duration = kwargs.get(ATTR_DURATION, None)
+        volume = kwargs.get(ATTR_VOLUME_LEVEL, None)
 
         set_dps = {}