|
@@ -38,6 +38,7 @@ class TuyaLocalSiren(TuyaLocalEntity, SirenEntity):
|
|
|
self._tone_dp = dps_map.get("tone", None)
|
|
self._tone_dp = dps_map.get("tone", None)
|
|
|
self._volume_dp = dps_map.get("volume_level", None)
|
|
self._volume_dp = dps_map.get("volume_level", None)
|
|
|
self._duration_dp = dps_map.get("duration", None)
|
|
self._duration_dp = dps_map.get("duration", None)
|
|
|
|
|
+ self._switch_dp = dps_map.get("switch", None)
|
|
|
self._init_end(dps_map)
|
|
self._init_end(dps_map)
|
|
|
# All control of features is through the turn_on service, so we need to
|
|
# All control of features is through the turn_on service, so we need to
|
|
|
# support that, even if the siren does not support direct control
|
|
# support that, even if the siren does not support direct control
|
|
@@ -62,6 +63,8 @@ class TuyaLocalSiren(TuyaLocalEntity, SirenEntity):
|
|
|
@property
|
|
@property
|
|
|
def is_on(self):
|
|
def is_on(self):
|
|
|
"""Return whether the siren is on."""
|
|
"""Return whether the siren is on."""
|
|
|
|
|
+ if self._switch_dp:
|
|
|
|
|
+ return self._switch_dp.get_value(self._device)
|
|
|
if self._tone_dp:
|
|
if self._tone_dp:
|
|
|
return self._tone_dp.get_value(self._device) != "off"
|
|
return self._tone_dp.get_value(self._device) != "off"
|
|
|
|
|
|
|
@@ -69,10 +72,11 @@ class TuyaLocalSiren(TuyaLocalEntity, SirenEntity):
|
|
|
tone = kwargs.get("tone", None)
|
|
tone = kwargs.get("tone", None)
|
|
|
duration = kwargs.get("duration", None)
|
|
duration = kwargs.get("duration", None)
|
|
|
volume = kwargs.get("volume", None)
|
|
volume = kwargs.get("volume", None)
|
|
|
|
|
+
|
|
|
set_dps = {}
|
|
set_dps = {}
|
|
|
|
|
|
|
|
if self._tone_dp:
|
|
if self._tone_dp:
|
|
|
- if tone is None:
|
|
|
|
|
|
|
+ if tone is None and not self._switch_dp:
|
|
|
tone = self._tone_dp.get_value(self._device)
|
|
tone = self._tone_dp.get_value(self._device)
|
|
|
if tone == "off":
|
|
if tone == "off":
|
|
|
tone = self._default_tone
|
|
tone = self._default_tone
|
|
@@ -104,9 +108,17 @@ class TuyaLocalSiren(TuyaLocalEntity, SirenEntity):
|
|
|
**self._volume_dp.get_values_to_set(self._device, volume),
|
|
**self._volume_dp.get_values_to_set(self._device, volume),
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if self._switch_dp and not self.is_on:
|
|
|
|
|
+ set_dps = {
|
|
|
|
|
+ **set_dps,
|
|
|
|
|
+ **self._switch_dp.get_values_to_set(self._device, True),
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
await self._device.async_set_properties(set_dps)
|
|
await self._device.async_set_properties(set_dps)
|
|
|
|
|
|
|
|
async def async_turn_off(self) -> None:
|
|
async def async_turn_off(self) -> None:
|
|
|
"""Turn off the siren"""
|
|
"""Turn off the siren"""
|
|
|
- if self._tone_dp:
|
|
|
|
|
|
|
+ if self._switch_dp:
|
|
|
|
|
+ await self._switch_dp.async_set_value(self._device, False)
|
|
|
|
|
+ elif self._tone_dp:
|
|
|
await self._tone_dp.async_set_value(self._device, "off")
|
|
await self._tone_dp.async_set_value(self._device, "off")
|