Exemple #1
0
 def _set_device_volume(self, device: SoCo, volume: int):
     device.volume = volume
     logger.info('Volume of Sonos device with name \'%s\' changed to %d.',
                 device.player_name, device.volume)
Exemple #2
0
#!/usr/bin/env python3

from soco.core import SoCo
from sys import argv

sonos = SoCo("10.0.0.11")
vol_step = 5

if argv[1] == "line_in":
    sonos.switch_to_line_in()
    sonos.play()

if argv[1] == "+":
    sonos.volume = (int(sonos.volume / vol_step) + 1) * vol_step

if argv[1] == "-":
    sonos.volume = (int(sonos.volume / vol_step) - 1) * vol_step

if argv[1] == "set":
    sonos.volume = int(argv[2])

if argv[1] == "mute":
    sonos.mute = not (sonos.mute)