Sonos HTTP Api questions

Subforum for general discussions. Do not dump your questions/problems here, but try to find the subforum where it belongs!
leecollings
Posts: 78
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi
Domoticz version: 3.5021
Location: Essex, United Kingdom
Contact:

Sonos HTTP Api questions

Postby leecollings » Tuesday 10 January 2017 2:53

Hi everyone,

So I've just taken a look at the Sonos HTTP API as on https://github.com/jishi/node-sonos-http-api

I have a few questions, that I would just like to hear ideas from other users to get what I want to be able to do.

I would like this sequence of events to happen on the trigger of the doorbell switch:

1. Pause all sonos speakers
2. Play an MP3 file
3. Resume any players that were paused (ignoring any that were paused in the first place)

So I've been able to run individual json requests via HTTP (in a browser window), but I'd like to know how I can incorporate the three events above into a script or blockly (or whatever is best), to run as possible the 'ON' action of the doorbell switch?

kalinkamaen
Posts: 61
Joined: Sunday 04 January 2015 16:57
Target OS: Windows
Domoticz version:
Contact:

Re: Sonos HTTP Api questions

Postby kalinkamaen » Thursday 12 January 2017 14:19

Hello sir.

I can see that not many have given you an answear. This is not an directly answear to your question.
I am doing the exact same thing with my mail box. I am doing this with Eventghost. You can do this
without any script at all with sonos plugin for Eventghost.

leecollings
Posts: 78
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi
Domoticz version: 3.5021
Location: Essex, United Kingdom
Contact:

Re: Sonos HTTP Api questions

Postby leecollings » Thursday 12 January 2017 20:06

That doesn't help, and I'm not sure if you're a spam bot or not... firstly I'm not downloading a windows based program for many reasons!

I don't run Windows so that's not helpful. Also, that has no relevance to what I'm asking.


Sent from my iPhone using Tapatalk

leecollings
Posts: 78
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi
Domoticz version: 3.5021
Location: Essex, United Kingdom
Contact:

Re: Sonos HTTP Api questions

Postby leecollings » Thursday 12 January 2017 22:07

Anyone got any ideas to help me create a script?


Sent from my iPhone using Tapatalk

ferryversteeg
Posts: 1
Joined: Monday 12 December 2016 10:24
Target OS: Linux
Domoticz version:
Contact:

Re: Sonos HTTP Api questions

Postby ferryversteeg » Saturday 14 January 2017 15:34

Hi,

Using this site: https://github.com/duncan3dc/sonos

I made a php script thats doing what you want for one sonos speaker.
The script below saves the current state, plays the doorbell mp3 and restores the state.

Cheers,

Ferry

-------------------------------
#!/usr/bin/php
<?php

require_once "vendor/autoload.php";
use duncan3dc\Sonos\Network;
use duncan3dc\Sonos\Controller;
$sonos = new Network(new \Doctrine\Common\Cache\ArrayCache);

$controller = $sonos->getControllerByIP("10.1.1.140");
$state = $controller->exportState(true);
$queue = $controller->getQueue();
$queue->clear();
$queue->addTrack("http://10.1.1.14:8080/faralley/doorbell.mp3");
$controller->useQueue();

if ($argc > 1) {
$controller->setVolume($argv[1]);
} else {
$controller->setVolume(10);
}

$controller->play();

while (true) {
sleep(1);
if ($controller->getState() !== Controller::STATE_PLAYING) {
break;
}
}

$controller->restoreState($state);

?>

bsmeding
Posts: 11
Joined: Tuesday 28 October 2014 19:29
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Sonos HTTP Api questions

Postby bsmeding » Monday 16 January 2017 14:37

If you upload your (doorbell.)mp3 file to the folder : static/clips
then you can create a script to call to these three URLS:


so in domoticz/scripts folder create : doorbell.sh
in you doorbell switch create run script and point this to your script : script://home/pi/domoticz/scripts/doorbell.sh


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest