From 45602384997cc541d246bc9cabdfa0c683cd0b1d Mon Sep 17 00:00:00 2001 From: cdnninja Date: Fri, 27 Sep 2024 22:01:03 -0600 Subject: [PATCH] feat: enable alarm setting in config (#97) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- yoto_api/YotoAPI.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/yoto_api/YotoAPI.py b/yoto_api/YotoAPI.py index c847a42..2f8bb68 100644 --- a/yoto_api/YotoAPI.py +++ b/yoto_api/YotoAPI.py @@ -327,6 +327,22 @@ def set_player_config(self, token: Token, player_id: str, config: YotoPlayerConf config_payload["nightAmbientColour"] = config.night_ambient_colour if config.night_max_volume_limit: config_payload["nightMaxVolumeLimit"] = str(config.night_max_volume_limit) + if config.alarms: + alarm_payload = [] + for alarm in config.alarms: + payload = ( + str(alarm.days_enabled) + + "," + + str(alarm.time) + + "," + + str(alarm.sound_id) + + ",,," + + str(alarm.volume) + + "," + + str(int(alarm.enabled)) + ) + alarm_payload.append(payload) + config_payload["alarms"] = alarm_payload data = {"deviceId": player_id, "config": config_payload} headers = self._get_authenticated_headers(token) response = requests.put(url, headers=headers, data=json.dumps(data)).json()