소스 검색

Anko fan: speed is actually a string

Rather than scaling it, use a mapping.

Issue #22
Jason Rumney 2 년 전
부모
커밋
aa6d237289
2개의 변경된 파일19개의 추가작업 그리고 7개의 파일을 삭제
  1. 17 5
      custom_components/tuya_local/devices/anko_fan.yaml
  2. 2 2
      tests/devices/test_anko_fan.py

+ 17 - 5
custom_components/tuya_local/devices/anko_fan.yaml

@@ -17,13 +17,25 @@ primary_entity:
         - dps_val: sleep
           value: sleep
     - id: 3
-      type: integer
+      type: string
       name: speed
-      range:
-        min: 0
-        max: 8
       mapping:
-        - scale: 0.08
+        - dps_val: "1"
+          value: 13
+        - dps_val: "2"
+          value: 25
+        - dps_val: "3"
+          value: 37
+        - dps_val: "4"
+          value: 50
+        - dps_val: "5"
+          value: 63
+        - dps_val: "6"
+          value: 75
+        - dps_val: "7"
+          value: 87
+        - dps_val: "8"
+          value: 100
     - id: 4
       type: string
       name: oscillate

+ 2 - 2
tests/devices/test_anko_fan.py

@@ -107,12 +107,12 @@ class TestAnkoFan(SwitchableTests, BasicNumberTests, TuyaDeviceTestCase):
 
     async def test_set_speed_in_normal_mode(self):
         self.dps[PRESET_DPS] = "normal"
-        async with assert_device_properties_set(self.subject._device, {SPEED_DPS: 2}):
+        async with assert_device_properties_set(self.subject._device, {SPEED_DPS: "2"}):
             await self.subject.async_set_percentage(25)
 
     async def test_set_speed_in_normal_mode_snaps(self):
         self.dps[PRESET_DPS] = "normal"
-        async with assert_device_properties_set(self.subject._device, {SPEED_DPS: 6}):
+        async with assert_device_properties_set(self.subject._device, {SPEED_DPS: "6"}):
             await self.subject.async_set_percentage(80)
 
     def test_extra_state_attributes(self):