mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-23 03:33:35 +00:00
Allow passing alarm parameter overrides
This commit is contained in:
parent
123ea107b1
commit
0f7e007663
@ -136,9 +136,29 @@ class Alarm(SmartModule):
|
|||||||
src = self._device.sys_info["in_alarm_source"]
|
src = self._device.sys_info["in_alarm_source"]
|
||||||
return src if src else None
|
return src if src else None
|
||||||
|
|
||||||
async def play(self) -> dict:
|
async def play(
|
||||||
"""Play alarm."""
|
self,
|
||||||
return await self.call("play_alarm")
|
*,
|
||||||
|
duration: int | None = None,
|
||||||
|
volume: Literal["low", "normal", "high"] | None,
|
||||||
|
sound: str | None = None,
|
||||||
|
) -> dict:
|
||||||
|
"""Play alarm.
|
||||||
|
|
||||||
|
The optional *duration*, *volume*, and *sound* to override the device settings.
|
||||||
|
*volume* can be set to 'low', 'normal', or 'high'.
|
||||||
|
*duration* is in seconds.
|
||||||
|
See *alarm_sounds* for the list of sounds available for the device.
|
||||||
|
"""
|
||||||
|
params: dict[str, str | int] = {}
|
||||||
|
if duration is not None:
|
||||||
|
params["alarm_duration"] = duration
|
||||||
|
if volume is not None:
|
||||||
|
params["alarm_volume"] = volume
|
||||||
|
if sound is not None:
|
||||||
|
params["alarm_type"] = sound
|
||||||
|
|
||||||
|
return await self.call("play_alarm", params)
|
||||||
|
|
||||||
async def stop(self) -> dict:
|
async def stop(self) -> dict:
|
||||||
"""Stop alarm."""
|
"""Stop alarm."""
|
||||||
|
Loading…
Reference in New Issue
Block a user