Skip to content

Commit

Permalink
Fix #635: Siren duration on C520WS
Browse files Browse the repository at this point in the history
  • Loading branch information
JurajNyiri committed Jul 21, 2024
1 parent 4e28609 commit d2530aa
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions custom_components/tapo_control/number.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,21 @@ async def async_set_native_value(self, value: float) -> None:
self._controller.setHubSirenConfig, int(value)
)
else:
result = await self._hass.async_add_executor_job(
self._controller.executeFunction,
"setAlarmConfig",
{"msg_alarm": {self.value_key: int(value)}},
)
if self.typeOfAlarm == "getAlarm":
result = await self._hass.async_add_executor_job(
self._controller.setAlarm,
self.alarm_enabled == "on",
"sound" in self.alarm_mode,
"siren" in self.alarm_mode or "light" in self.alarm_mode,
None,
int(value),
)
elif self.typeOfAlarm == "getAlarmConfig":
result = await self._hass.async_add_executor_job(
self._controller.executeFunction,
"setAlarmConfig",
{"msg_alarm": {self.value_key: int(value)}},
)
if "error_code" not in result or result["error_code"] == 0:
self._attr_state = value
self.async_write_ha_state()
Expand All @@ -403,3 +413,5 @@ def updateTapo(self, camData):
self._attr_state = STATE_UNAVAILABLE
else:
self._attr_state = camData["alarm_config"][self.value_key]
self.alarm_enabled = camData["alarm_config"]["automatic"] == "on"
self.alarm_mode = camData["alarm_config"]["mode"]

0 comments on commit d2530aa

Please sign in to comment.