8000 Add missing type hints to alarm module by rytilahti · Pull Request #1111 · python-kasa/python-kasa · GitHub
[go: up one dir, main page]

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions kasa/smart/modules/alarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from __future__ import annotations

from typing import Literal

from ...feature import Feature
from ..smartmodule import SmartModule

Expand Down Expand Up @@ -94,7 +96,7 @@ def _initialize_features(self):
)

@property
def alarm_sound(self):
def alarm_sound(self) -> str:
"""Return current alarm sound."""
return self.data["get_alarm_configure"]["type"]

Expand All @@ -113,11 +115,11 @@ def alarm_sounds(self) -> list[str]:
return self.data["get_support_alarm_type_list"]["alarm_type_list"]

@property
def alarm_volume(self):
def alarm_volume(self) -> Literal["low", "normal", "high"]:
"""Return alarm volume."""
return self.data["get_alarm_configure"]["volume"]

async def set_alarm_volume(self, volume: str):
async def set_alarm_volume(self, volume: Literal["low", "normal", "high"]):
"""Set alarm volume."""
payload = self.data["get_alarm_configure"].copy()
payload["volume"] = volume
Expand All @@ -134,10 +136,10 @@ def source(self) -> str | None:
src = self._device.sys_info["in_alarm_source"]
return src if src else None

async def play(self):
async def play(self) -> dict:
"""Play alarm."""
return await self.call("play_alarm")

async def stop(self):
async def stop(self) -> dict:
"""Stop alarm."""
return await self.call("stop_alarm")
0