I’ve been trying to get the Sonos Binding to function as a wake up music alarm via a radio on line-in.
My plan was to define the channel for “playlinein” in an item and then via a rule, get it activated every morning.
So, that didn’t work out. I then set up a switch on my sitemap that I was thinking I could just set “ON” to test if this channel is even working. Turns out it doesn’t work either.
My logs didn’t report any errors so it would seem that although this channel is defined through the “thing”, it doesn’t work.
I also set up the line-in indicator channel to see if it provides an indication when I change to line-in through the Sonos software, but that doesn’t work either. I know that I am using the correct Player definition (I have 5 sonos devices in my house), because using the same “RINCON_xxxxxx” I can control play/pause/volume.
So what I ended up doing is setting this up on my openhab server using cron and a python script.
#!/usr/bin/env python
'''
morning_music.py
Script that gets activated by cron to change to line-in
to play the current input.
'''
import soco
global SonosPlayer
global SonosLivingRoom
zone_list = list(soco.discover())
for zone in zone_list:
if zone.player_name == 'Playroom':
SonosPlayer = zone
if zone.player_name == 'Living Room':
SonosLivingRoom = zone
SonosPlayer.switch_to_line_in()
SonosPlayer.play()
SonosLivingRoom.volume = 70
In my case I have a Playroom (Play:5) with the radio hooked up on line-in and my Living Room (Play:5) as the actual device I am interested in hearing the morning radio on. They were grouped via Sonos software with the Playroom as the group controller. I have a simple cron job that kicks off the script every morning at 07:30.
If you want to try this, you can install the “soco” class using: sudo pip install soco
Note: Sonos does have an Alarm function that can play an Internet Radio Station but this is not useful in my case since the station I want to wake up with doesn’t stream. Sonos does not support Alarm with Line-in.