Ver código fonte

Add support for Asakuki aroma diffuser

Issue #473

- light: adjusted to accept format with rgb only (no hsv)
  I initially thought this would help to support the inconsistant 6/7
  byte format for this device, but it still needs to set the hsv when
  setting the colour, even if it can read just the rgb.
Jason Rumney 3 anos atrás
pai
commit
eb047b4f1d

+ 2 - 0
ACKNOWLEDGEMENTS.md

@@ -203,3 +203,5 @@ Further device support has been made with the assistance of users.  Please consi
 - [kytro](https://github.com/kytro) for assistaing with support for Anko smart kettles and MoeBot mowers.
 - [Oglaf](https://github.com/Oglaf) for contributing support for Kabum Smart 500 vacuum cleaners.
 - [Whytey](https://github.com/Whytey/pymoebot) for investigation work into the MoeBot protocol.
+- [launchm](https://github.com/launchm) for assisting with support for Asakuki aroma diffusers.
+

+ 1 - 0
DEVICES.md

@@ -160,6 +160,7 @@
 
 ### Aroma diffusers
 
+- Asakuki aroma diffuser with light
 - YYM-805SW aroma diffuser with nightlight
 
 ### Kitchen Appliances

+ 116 - 0
custom_components/tuya_local/devices/asakuki_diffuser.yaml

@@ -0,0 +1,116 @@
+name: Asakuki aroma diffuser
+products:
+  - id: 6ASdNwe9IdaewQEl
+primary_entity:
+  entity: fan
+  icon: "mdi:scent"
+  dps:
+    - id: 11
+      type: boolean
+      name: switch
+    - id: 13
+      type: string
+      name: speed
+      mapping:
+        - dps_val: "0"
+          value: 50
+        - dps_val: "1"
+          value: 100
+secondary_entites:
+  - entity: light
+    dps:
+      - id: 1
+        type: boolean
+        name: switch
+      - id: 109
+        name: color_mode
+        type: string
+        mapping:
+          - dps_val: white
+            value: white
+          - dps_val: colour
+            value: Color
+          - dps_val: colourfull
+            value: Mood
+      - id: 111
+        name: brightness
+        type: integer
+        range:
+          min: 0
+          max: 255
+      - id: 108
+        name: color_data
+        type: hex
+        format:
+          - name: r
+            bytes: 1
+            range:
+              min: 0
+              max: 255
+          - name: g
+            bytes: 1
+            range:
+              min: 0
+              max: 255
+          - name: b
+            bytes: 1
+            range:
+              min: 0
+              max: 255
+          - name: h
+            bytes: 2
+            range:
+              min: 0
+              max: 360
+          - name: s
+            bytes: 1
+            range:
+              min: 0
+              max: 100
+          - name: v
+            bytes: 1
+            range:
+              min: 0
+              max: 255
+  - entity: select
+    name: Mood
+    icon: "mdi:palette"
+    category: config
+    dps:
+      - id: 110
+        type: string
+        name: option
+        mapping:
+          - dps_val: "1"
+            value: Mood 1
+          - dps_val: "2"
+            value: Mood 2
+          - dps_val: "3"
+            value: Mood 3
+  - entity: select
+    name: Color
+    icon: "mdi:palette"
+    category: config
+    dps:
+      - id: 108
+        type: hex
+        name: option
+        mapping:
+          - dps_val: "ff00000064ff"
+            value: Red
+          - dps_val: "ffa5002764ff"
+            value: Orange
+          - dps_val: "ffff003c64ff"
+            value: Yellow
+          - dps_val: "00ff007864ff"
+            value: Green
+          - dps_val: "0000fff064ff"
+            value: Blue
+          - dps_val: "4b008201136482"
+            value: Indigo
+          - dps_val: "7f00ff010e64ff"
+            value: Violet
+          - dps_val: "ff6ec7014391ff"
+            value: Pink
+          - dps_val: "00ffff8464ff"
+            value: Cyan

+ 11 - 5
custom_components/tuya_local/light.py

@@ -171,11 +171,17 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
                     rgbhsv[n] = round(scale * v)
                     idx += 1
 
-                h = rgbhsv["h"]
-                s = rgbhsv["s"]
-                # convert RGB from H and S to seperate out the V component
-                r, g, b = color_util.color_hs_to_RGB(h, s)
-                w = rgbhsv["v"]
+                if "h" in rgbhsv and "s" in rgbhsv and "v" in rgbhsv:
+                    h = rgbhsv["h"]
+                    s = rgbhsv["s"]
+                    # convert RGB from H and S to seperate out the V component
+                    r, g, b = color_util.color_hs_to_RGB(h, s)
+                    w = rgbhsv["v"]
+                else:
+                    r = rgbhsv.get("r")
+                    g = rgbhsv.get("g")
+                    b = rgbhsv.get("b")
+                    w = self.brightness
                 return (r, g, b, w)
 
     @property