An open API service indexing awesome lists of open source software.

https://github.com/fourstepper/sonos-scheduler

Stop Sonos speaker playback on a schedule - PowerShell and Python/SoCo solutions for Windows Task Scheduler
https://github.com/fourstepper/sonos-scheduler

Last synced: about 1 month ago
JSON representation

Stop Sonos speaker playback on a schedule - PowerShell and Python/SoCo solutions for Windows Task Scheduler

Awesome Lists containing this project

README

          

# Sonos Scheduled Stop

Stop Sonos speaker playback on a schedule using Windows Task Scheduler.

Sonos alarms can start music, but there's no built-in way to schedule a stop. These scripts fill that gap — useful for businesses that want music during operating hours only.

Two methods are provided — pick whichever suits your setup.

## Method 1: PowerShell (zero dependencies)

Works on any Windows machine out of the box.

### Setup

1. Edit `powershell/stop_sonos.ps1` and replace the IP addresses with your Sonos speakers
2. Test it: right-click the `.ps1` file -> "Run with PowerShell"

### Schedule with Task Scheduler

1. Open **Task Scheduler** (`taskschd.msc`)
2. **Create Basic Task** -> name it "Stop Sonos Music"
3. **Trigger**: Daily (or Weekly for specific days), set your closing time
4. **Action**: Start a Program
- **Program/script**: `powershell`
- **Arguments**: `-ExecutionPolicy Bypass -File "C:\Scripts\stop_sonos.ps1"`
5. In Properties:
- Check **"Run whether user is logged on or not"**
- Uncheck **"Start only if the computer is on AC power"**

## Method 2: Python + SoCo

Supports auto-discovery — no need to hardcode IPs.

### Setup

```bash
pip install -r python/requirements.txt
```

### Usage

```bash
# Stop all speakers (auto-discover)
python python/stop_sonos.py

# Stop a specific speaker by IP
python python/stop_sonos.py --ip 192.168.1.10

# Stop a specific speaker by room name
python python/stop_sonos.py --room "Office"
```

### Schedule with Task Scheduler

1. Open **Task Scheduler** (`taskschd.msc`)
2. **Create Basic Task** -> name it "Stop Sonos Music"
3. **Trigger**: Daily (or Weekly for specific days), set your closing time
4. **Action**: Start a Program
- **Program/script**: `python`
- **Arguments**: `C:\path\to\python\stop_sonos.py`
5. In Properties:
- Check **"Run whether user is logged on or not"**
- Uncheck **"Start only if the computer is on AC power"**

## Finding your speaker IP

Open the Sonos app -> Settings -> System -> tap the speaker name -> IP address is shown there.

## Notes

- The PC must be on the **same network** as the Sonos speakers
- Make sure the PC **doesn't sleep** before the scheduled time (or enable wake timers in Task Scheduler conditions)
- The PowerShell method has zero dependencies; the Python method requires Python and the `soco` package but supports auto-discovery