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):