Windows batch file for overnight reset #58
philhemel
started this conversation in
Show and Tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi folks, firstly HUGE thanks to @pwt for this awesome project!
Thought I'd share the following batch file in case it's of help to anyone else.
Every night I like to ungroup all speakers and reset volumes to a low value, to avoid music in unexpected locations at loud volumes the next day (e.g. after a party the night before!!).
I use a standalone compiled EXE of soco-cli (see discussions/56), but it should work fine with normal Python-based sonos.exe:
================================================
@echo off
cls
echo Changing Sonos Settings...
C:
cd "C:\Tools\Sonos"
Sonos.exe wait 0s ^
: "Bedroom" if_stopped ungroup_all_in_group ^
: "Kitchen" if_stopped ungroup_all_in_group ^
: "Lounge" if_stopped ungroup_all_in_group ^
: "Phil" if_stopped ungroup_all_in_group ^
: "Bedroom" if_stopped volume 20 ^
: "Kitchen" if_stopped volume 20 ^
: "Lounge" if_stopped volume 20 ^
: "Phil" if_stopped volume 20 ^
: "Bedroom" if_stopped mute off ^
: "Kitchen" if_stopped mute off ^
: "Lounge" if_stopped mute off ^
: "Phil" if_stopped mute off ^
: wait 0s
if %ERRORLEVEL% EQU 0 goto SUCCESS
echo.
pause
goto END
:SUCCESS
echo.
echo Done!
timeout 5
:END
================================================
NOTES:
The main command is ONE LINE:
'sonos.exe "Speaker" command value : "Speaker" command value'
etc, split by the carat symbol for ease of reading/editing. See:
https://stackoverflow.com/questions/69068/split-long-commands-in-multiple-lines-through-windows-batch-file
The 'wait 0s' commands are there JUST to allow first and last commands to be exact same format as the rest!
I used 'if_stopped' to prevent active speakers from being disturbed while testing the batch file, and to prevent a muted / zero-volume playing speaker from blasting out in the night!!
I found that the simpler 'ungroup' command messed with queues and stopped playback on playing speakers, even if the speaker WASN'T grouped, but 'ungroup_all_in_group' works much better
I trigger the batch file via a standard Windows Task Scheduler entry
Beta Was this translation helpful? Give feedback.
All reactions