Skip to content

Commit

Permalink
common: add parse functions
Browse files Browse the repository at this point in the history
Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
  • Loading branch information
Noltari committed Apr 3, 2024
1 parent 8c555b8 commit 12b4e0d
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions aioairzone_cloud/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,31 @@ class TemperatureUnit(IntEnum):

CELSIUS = 0
FAHRENHEIT = 1


def parse_bool(data: Any) -> bool | None:
"""Convert data to bool."""
if data is not None:
return bool(data)
return None


def parse_float(data: Any) -> float | None:
"""Convert data to float."""
if data is not None:
return float(data)
return None


def parse_int(data: Any) -> int | None:
"""Convert data to int."""
if data is not None:
return int(data)
return None


def parse_str(data: Any) -> str | None:
"""Convert data to string."""
if data is not None:
return str(data)
return None

0 comments on commit 12b4e0d

Please sign in to comment.