Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add night_mode command #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions socos/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down