From b6e0c3541dfd8eefc3328954c0bff1cb69038c5f Mon Sep 17 00:00:00 2001 From: Yannik Stein Date: Sun, 5 Jan 2020 19:47:16 +0100 Subject: [PATCH] Add night_mode command Add command to control the night mode setting of a speaker. --- socos/core.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/socos/core.py b/socos/core.py index a0cabcc..cbfec77 100644 --- a/socos/core.py +++ b/socos/core.py @@ -492,6 +492,24 @@ def state(sonos): """Get the current state of a device / group""" return sonos.get_current_transport_info()['current_transport_state'] + @staticmethod + @add_command() + def night_mode(sonos, *args): + """Change or show the night mode setting of a device + Accepted values: true, false + """ + def night_mode_str(): + return "Night mode: {}".format(sonos.night_mode) + + if sonos.night_mode is None: + return "Speaker has no night mode" + + if not args: + return night_mode_str() + + sonos.night_mode = args[0].lower() == 'true' + return night_mode_str() + @staticmethod @add_command() def player_name(sonos, *args):