diff --git a/src/pyblu/_entities.py b/src/pyblu/_entities.py index 558ee7c..00fd6d6 100644 --- a/src/pyblu/_entities.py +++ b/src/pyblu/_entities.py @@ -37,6 +37,9 @@ class Status: total_seconds: float """Total track length in seconds""" + sleep: int + """Sleep timer in minutes. 0 means the sleep timer is off.""" + @dataclass class PairedPlayer: diff --git a/src/pyblu/_parse.py b/src/pyblu/_parse.py index 5116813..e752dc4 100644 --- a/src/pyblu/_parse.py +++ b/src/pyblu/_parse.py @@ -79,6 +79,7 @@ def parse_status(response_dict: dict[str, Any]) -> Status: mute_volume_db=chained_get(response_dict, "status", "muteDb", _map=int), seconds=chained_get(response_dict, "status", "secs", _map=int), total_seconds=chained_get(response_dict, "status", "totlen", _map=float), + sleep=chained_get(response_dict, "status", "sleep", _map=int, default=0), ) return status diff --git a/tests/test_parse.py b/tests/test_parse.py index f2d9299..0ef2a3d 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -1,5 +1,7 @@ +import xmltodict + from pyblu import PairedPlayer -from pyblu._parse import parse_slave_list +from pyblu._parse import parse_slave_list, parse_status def test_sync_status_no_slave(): @@ -41,3 +43,15 @@ def test_parse_slave_list_multiple_elements(): PairedPlayer(ip="1.1.1.1", port=11000), PairedPlayer(ip="2.2.2.2", port=11000), ] + + +def test_parse_status_default_sleep(): + data = """ + + """ + + response_dict = xmltodict.parse(data) + + status = parse_status(response_dict) + + assert status.sleep == 0 diff --git a/tests/test_player.py b/tests/test_player.py index 4282158..e74b949 100644 --- a/tests/test_player.py +++ b/tests/test_player.py @@ -91,6 +91,8 @@ async def test_status(): 10 100 + + 15 """, ) @@ -116,6 +118,8 @@ async def test_status(): assert status.seconds == 10 assert status.total_seconds == 100.0 + assert status.sleep == 15 + async def test_sync_status(): with aioresponses() as mocked: