Skip to main content

Linn DS Alarm Function

Update 2014 - An alternative to this is available on GitHub which uses Node.js and should be cross platform. Linn DS Playlist and Alarm Server

Switching the radio on in the kitchen in the morning is a low priority amongst setting table, pouring cereals, carrying children, etc. The Sonos has an alarm clock facility which allows you to switch on the radio at a set time avoiding hassle of starting a controller.

When I upgraded to my Linn Sneaky DS, I no longer had this function, though the remote control made it easy if I forgot to take my phone downstairs with me.

Last week I decided to figure it out. I have a Linux machine which runs Ubuntu and runs all the media servers, backups and network shares. I decided to investigate how to control my DS from the command line.

Conveniently, the DS can be controlled via a web api, so after reading the docs and a few examples I was able to switch off and on and change source via Postman (Chrome REST client).

I then set about writing a curl script to send the commands and package this up as a shell script.

One final problem was discovering the IP address of the DS which I solved by using gupnp-tools which has a scanner; this scans my network for UPNP devices and since I know the UUID of the DS I can extract the correct IP address.

By adding the script to my Linux box' crontab, the DS starts on the radio each weekday morning.

How it works


Need to install gupnp-tools which provides gssdp-discover.

I created a script called discover.sh which takes a parameter of the UUID of a Upnp device and returns the IP address:

#!/bin/sh
gssdp-discover -t ${1} -n 3 | grep Location | sed 's/.*http:\/\///' | sed 's/:.....\/.*//'

Next is a script called source.sh to set the source of the DS:

#!/bin/sh
curl -X POST -d @${2} $1/Ds/Product/control --header "Content-Type:text/xml" --header "Accept:text/xml" --header "SOAPAction:urn:av-openhome.org:service:Product:1#SetSourceIndex"

This takes in 2 parameters, the first is the IP address of the device you want to control and the second is a file containing an XML body containing details of which source to set on the device, in this case, it is the radio function (source Id 1):

radio.xml
<?xml version="1.0"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Body s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    <u:SetSourceIndex xmlns:u="urn:av-openhome.org:service:Product:1">
      <Value>1</Value>
    </u:SetSourceIndex>
  </s:Body>
</s:Envelope>

Finally it's all put together in the following script. Set the SCRIPTS property to where you've saved the files above. Set the UUID property to the UUID of your DS - you'll need to scan your network to find this. In Windows, my DSs appear in the network view of Windows Explorer and I can see the unique identifier (UUID) if I right click the DS and view properties.

#!/bin/sh
SCRIPTS=/home/barry/scripts/ds
RADIO=${SCRIPTS}/radio.xml
UUID=uuid:4c494e4e-0026-0f21-d74b-013330780171
DS=`${SCRIPTS}/discover.sh ${UUID}`
${SCRIPTS}/source.sh ${DS} ${RADIO}

Now just add it to your crontab:
45 6 * * 1-5 /home/barry/scripts/kitchen_radio.sh

Enjoy one less thing to do in the morning :)

Here's the api documentation for the DS:
http://docs.linn.co.uk/wiki/index.php/Developer:Davaar

Comments

Guussie said…
Hi barry, I have tried to modify your code in order to put a DS player in StandBy but I can't get it to work.

Would you have any suggestions on how to do this?

I want to put a DS player in standby from a Raspberry Pi.

Thanks!
Guussie said…
I ahem tried to modify your code with the objective to put a DS player in StandBy but can't get it to work.

The discover code works but I seem to have mistakes in the xml portion.

Would you be able to point me in the right direction?

I want to switch off a DSi from a Raspberry Pi.

Thanks!
Barry said…
To put the Ds into standby, you'd need to use the Product service. Assuming Davaar > 50, the Xml will look something like this:





1




And the command would look a bit like:

curl -X POST -d @${2} $1/Ds/Product/control --header "Content-Type:text/xml" --header "Accept:text/xml" --header "SOAPAction:urn:av-openhome.org:service:Product:2#SetStandby"

This was written some time ago and I've since moved on to either:

Upnp Playlist Service - this has basic alarm clock functionality
https://github.com/bazwilliams/upnp-playlist-service

Openhome device Python library - this provides a basic python library - you could set standby functionality using this instead.
https://github.com/bazwilliams/openhomedevice

Home Assisant - A Smart Home application that can run on a Raspberry Pi, now supports openhome devices. This is what I use.
https://home-assistant.io/
https://home-assistant.io/components/media_player.openhome/

Let me know how you get on!
Barry said…
That's annoying - XML doesn't work in Blogger comments :(
Barry said…
Basically replace SetSourceIndex with SetStandby
Guussie said…
> Basically replace SetSourceIndex with SetStandby

I tried that but could't get it to work.

But I found a simpler solution through the Linn Forum.

https://forums.linn.co.uk/bb/showthread.php?tid=16758&pid=429173#pid429173

I have now combined that with your discover.sh and it works very nicely. I will post it soon, once I have cleaned up things.

Thanks for your help!

Barry said…
No worries.

I would recommend the Home Assistant solution though - hooks into any other smart home equipment you may have - including Alexa or Google Home.

Great having my Ds switch off when I leave the house and change colour based on the source!

I wrote the openhome support :)
Guussie said…
I installed the Home Assistant on my test rig. Seems to work OK but the openhome component does not install correctly, even after updating the configuration file.

Looks like an very interesting platform and I will investigate further. Thanks for this suggestion!
Guussie said…
https://github.com/guussie/PiDSController/wiki

Popular posts from this blog

Howto: Ubuntu 8.10, Dell 5530, 3G/WWan and GPS

There is an updated howto on the Dell 5530 using my own python based monitoring tool at http://blog.bjw.me.uk/2009/03/dell-5530ericsson-f3507g-on-linux.html Introduction Here is a Howto document for getting the Dell 5530 wwan card working along with the onboard GPS under Ubuntu 8.10. This card does not work conveniently with the bundled Network Manager software, but replacing NetworkManager with other utilities will give the ability to get online using a pretty GUI and not have to resort to using wvdial and the command line... It should also work with the Ericsson f3507g as I believe the Dell 5530 is a rebadged version of this module. Check Hardware First you need to check the modem is detected correctly. On my computer, the modem is detected out of the box by the cdc_acm module and exposes three serial ports (/dev/ttyACM[0,1,2]) for communication. Check by running: dmesg | grep ACM Mine shows the following: [ 34.385302] cdc_acm 1-6:1.1: ttyACM0: USB ACM device [

Dell 5530/Ericsson f3507g on Linux

A few months back I posted a howto guide on getting this mobile broadband card working with Linux, what I failed to mention was I continued to work on these scripts. I feel it is appropriate to post a status update on what I use now especially given there appears to be no further updates on the NetworkManager front. I no longer use UMTSMon as I found it relied on AT+CSQ for the signal quality and during UMTS and HSPA connections, the f3507g/dell 5530 returns either the previous GPRS value or 99,99 which UMTSMon considers as no connection available. I've used a simplified wvdial.conf scripts and now do the rest of the radio work using python. wvdial.conf # Author: Barry John Williams # Creative Commons Attribute-Share Alike 2.5 UK:Scotland Licence [Dialer defaults] New PPPD = yes Stupid Mode = 1 Modem Type = ACM Modem Modem = /dev/ttyACM1 Init1 = AT Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0 Init3 = AT+CGDCONT=1,"ip","internet" Baud = 460800 I