4
0
Эх сурвалжийг харах

Improve motion sensor light support based on Arlec PR.

PR #356, improvements to #282.
Jason Rumney 3 жил өмнө
parent
commit
4b8ac6568a

+ 1 - 0
ACKNOWLEDGEMENTS.md

@@ -161,3 +161,4 @@ Further device support has been made with the assistance of users.  Please consi
 - [ppprpd](https://github.com/ppprpd) for contributing support for Netmostat N-1 thermostats.
 - [Pokemowka25](https://github.com/Pokemowka26) for assistance supporting Kyvol EA200 humidifiers.
 - [spuljko](https://github.com/spuljko) for contributing support for YYM-805SW aroma diffuser with nightlight.
+- [raphaelcouzet](https://github.com/raphaelcouzet) for contributing support for Arlec motion sensor lights which were used to improve Deta motion light support.

+ 1 - 1
DEVICES.md

@@ -209,7 +209,7 @@ generic configurations known to work with multiple brands of device.
 
 - Generic RGBCW/RGBWW lightbulb (confirmed with Lijun branded bulb, expected to match others also). Two versions - with and without scene/music modes and timer.
 - Atomi smart color string light
-- Deta motion sensor lights (DET100HA/DET102HA)
+- Deta/Arlec motion sensor lights (DET100HA/DET102HA/MAL315HA)
 - Dual-mode magic light string controller
 - Space Dog Music Lamp
 

+ 15 - 9
custom_components/tuya_local/devices/motion_sensor_light.yaml

@@ -4,6 +4,8 @@ products:
     name: Deta 360 Motion Sensor
   - id: 8mrw54ape8opgl69
     name: Deta Light Motion Sensor
+  - id: pxyhz90upglpoedu
+    name: Arlec MAL315HA
 primary_entity:
   entity: light
   dps:
@@ -20,6 +22,7 @@ primary_entity:
     - id: 102
       type: boolean
       name: switch
+      readonly: true
 secondary_entities:
   - entity: number
     name: Sensitivity
@@ -31,7 +34,9 @@ secondary_entities:
         name: value
         range:
           min: 0
-          max: 100
+          max: 4
+        mapping:
+          - invert: true 
   - entity: number
     name: Duration
     icon: "mdi:camera-timer"
@@ -42,7 +47,7 @@ secondary_entities:
         name: value
         unit: s
         range:
-          min: 0
+          min: 10
           max: 900
         mapping:
           - step: 10
@@ -56,13 +61,14 @@ secondary_entities:
         name: value
         unit: lx
         range:
-          min: 3
-          max: 2000
-  - entity: binary_sensor
-    name: Detect
-    category: diagnostic
-    class: presence
+          min: 0
+          max: 3900
+        mapping:
+          - invert: true
+  - entity: switch
+    name: Auto reset
+    category: config
     dps:
       - id: 106
         type: boolean
-        name: sensor
+        name: switch

+ 12 - 0
custom_components/tuya_local/devices/rgbcw_lightbulb.yaml

@@ -97,3 +97,15 @@ secondary_entities:
         mapping:
           - scale: 60
             step: 60
+  - entity: select
+    name: Scene
+    icon: "mdi:palette"
+    category: config
+    dps:
+      - id: 25
+        type: string
+        name: option
+        mapping:
+          - dps_val: 01
+            value: 
+            

+ 24 - 5
custom_components/tuya_local/generic/light.py

@@ -306,17 +306,36 @@ class TuyaLocalLight(TuyaLocalEntity, LightEntity):
                 }
 
         if self._switch_dps and not self.is_on:
-            settings = {
-                **settings,
-                **self._switch_dps.get_values_to_set(self._device, True),
-            }
+            if (
+                self._switch_dps.readonly
+                and self._effect_dps
+                and "on" in self._effect_dps.values(self._device)
+            ):
+                # Special case for motion sensor lights with readonly switch
+                # that have tristate switch available as effect
+                settings = settings | self._effect_dps.get_values_to_set(
+                    self._device, "on"
+                )
+            else:
+                settings = settings | self._switch_dps.get_values_to_set(
+                    self._device, True
+                )
 
         if settings:
             await self._device.async_set_properties(settings)
 
     async def async_turn_off(self):
         if self._switch_dps:
-            await self._switch_dps.async_set_value(self._device, False)
+            if (
+                self._switch_dps.readonly
+                and self._effect_dps
+                and "off" in _self._effect_dps.values(self._device)
+            ):
+                # Special case for motion sensor lights with readonly switch
+                # that have tristate switch available as effect
+                await self._effect_dps.async_set_value(self._device, "off")
+            else:
+                await self._switch_dps.async_set_value(self._device, False)
         elif self._brightness_dps:
             await self._brightness_dps.async_set_value(self._device, 0)
         else: