Sonos plugin

[quote=“jduchon, post:659, topic:169644”]Hello,
I only got one Play:3 and I have the error 500 in my log.[/quote]

As Play:3 has no line input, that could have been an explanation. But guessed has the same issue with Play:5.
I will disable the call to Browse “AI:” after the first error.

[quote=“jduchon, post:660, topic:169644”]@lolodomo

The “no icon” issue happens with all my (favorites) stations : France Inter, FIP, RMC… It’s with TuneIn service.
I use the latest Firefox browser on MacOS.

Jérôme[/quote]

I will verify again with these radio stations in particular.
I do my tests with Firefox and IE9 on Windows Seven.

I will verify again with these radio stations in particular. I do my tests with Firefox and IE9 on Windows Seven.
And I'll test tonight with the same software configuration on my side!

No icon with IE9 on W7 for : RMC, FIP and France Inter stations. But it works with France Info !?
Same behaviour with Firefox (and the empty frame is flickering).

The issue doesn’t seem to be linked to the OS neither the browser, since I the same behaviour for Firefox on MacOS (I didn’t noticed at first France Info was OK on my Macbook).

Ok i should be able to reprodice it and understand what’s wrong

[b]New version in trunk:

  • TuneIn radio station logo fixed
  • Browse “AI:” (to get list of line-in audio inputs) is called only one time if failed
  • URI for TuneIn is now TR: (PlayURI callback)[/b]

The way to get TuneIn station logo URL is proper than before. The URL is retrieved parsing the result of the URL: http://tunein.com/station/?StationId=XXXX

Browse with “AI:” is no more called as soon as it fails a first time. So you should get only one error (per Sonos device) after each reload.

The new code for Say callback is present but commented in trunk. Remains to decide in which case we use the normal way and in which case we download the file. And the code to get the Vera IP address has to be added.

Here is an update of what special URI you can use for SetURIToPlay and PlayURI callbacks in addition to the Sonos standard URI:

  • load or play a Sonos playlist by its name => use URI SQ: is the name of your playlist
  • load or play an audio input by its name => use URI AI: is the name of your audio input
  • load or play the local audio input => use URI AI:
  • load or play the local (internal) queue starting at the first track => use URI Q:
  • load or play the local (internal) queue starting at the track => use URI Q:
  • load or play a favorite radio by its name => use URI FR: is the name of the radio
  • load or play a tunein radio by its station id => use URI TR: is the number present in the Sonos URI just before “?sid=254”

So now, I think it remains only one thing to finish before the release: it is relative to the Say callback.

@guessed; what do you want as trigger to use either the normal or the alternative way to call Google traduction ? A setting through a variable that the user can adjust ?

Do you know how to get the IP of the Vera from lua ?

Regarding vera ip. The vera seems to have two interfaces up and running. eth0 and eth0:0. One of the ip:s is probably the open connection to micasaverde (remote access).

I have not found any easier way to fetch local-external-ip than doing an awk-hack.

Given the i18n reqs, I’d think we just switchover to the new TTS technique and give it to people to field prior to release. That’ll avoid the need to carry both options around.

I looked around and could only find a hokey Lua-based mechanism to determine IP. It might be simpler to use @hek’s soln for now, and do it just once at startup. Alternatively we can have a parameter for the IP address and have Vera emit a (Task) message if its not configured when the Say call comes in.

Just realized something. We could probably solve Say length problem pretty easy.

Google TTS has a fixed bit rate of 32kbps (=4000k bytes/s).

By dividing file length (in bytes) by 4000 we get the number of seconds the mp3 should play.

:smiley:

--  Find the Google TTS lenght of a file in seconds
--  filename: file name (32kbps mp3)
-- returns
--   len: length of file (in seconds)
--   asserts on error
function TTS_length(filename)
  local fh = assert(io.open(filename, "rb"))
  local len = assert(fh:seek("end"))
  fh:close()
  return len/4000
end

I think it will not work as we will check the length of the file before it is fully downloaded.
Or we have to change something in wget command to be sure that the os.execute returns only when the download is finished.

[quote=“lolodomo, post:648, topic:169644”][quote=“hek, post:645, topic:169644”]We could use the following to get veras external ip-address (maybe there is some easier way?).

/sbin/ifconfig | grep '\<inet\>' | sed -n '2p' | tr -s ' ' | cut -d ' ' -f3 | cut -d ':' -f2 [/quote]

I hope there is an easiest way to get it ;D[/quote]

How to get the output of os.execute in lua ? If I pass your command as parameter to os.execute, it returns 0 but how to get the output string (the IP) ?

Use [tt]io.popen(…)[/tt] instead of [tt]os.execute(…)[/tt]

[quote=“lolodomo, post:667, topic:169644”][b]New version in trunk:

  • TuneIn radio station logo fixed
  • Browse “AI:” (to get list of line-in audio inputs) is called only one time if failed
  • URI for TuneIn is now TR: (PlayURI callback)[/b][/quote]
    Verified that both these changes have fixed the problems that I was seeing. Also tested Say method whilst the radio was playing to validate push/pop of state information and that’s working well also.

I put a few screenshots into the Wiki page to showcase your work. We’ll need to chip in a bunch to bring that page up to speed, but we can do that little-by-little. For now, it looks like the bulk of the UI mods are in place.

[quote=“lolodomo, post:674, topic:169644”]I think it will not work as we will check the length of the file before it is fully downloaded.
Or we have to change something in wget command to be sure that the os.execute returns only when the download is finished.[/quote]
Exactly. If we were going that route, then I’d prefer to use [tt]io.popen(…)[/tt] on the [tt]wget[/tt] call, and leave out the “-q” option so we can see it download, and known when it’s finished before doing either a file-length calc (or a summation of the dot-count from [tt]wget[/tt] for rough 1k blocks)

ie. Default the timeout to 10s, “reset” it later when we know better :wink:

Ok, it work for retrieving the Vera IP address.

And it work too to run wget.

PS: note that the wget command ends very fast, meaning that Google provides the result file very fast. So my initial conclusion that os.execute returns before the end of downloading could have been an error.

Yup, looks like [tt]os.execute[/tt] is blocking whilst the command runs. We’ll want to background it if we use that technique, since we really don’t know how long it will block for, and Vera will “kill” anything running longer than 30/60s (UI4/UI5), esp since we cannot guarantee what will be “said” using this command, and how fast/slow the network link will be (eg 3G Dongle-modem, etc)

I ran a little test program that did:

luup.log("8888A") os.execute("sleep 20") luup.log("8888B")

and the LuaUPnP.log output was:

50 11/29/12 21:52:53.458 luup_log:0: 8888A <0x2f403680> 50 11/29/12 21:53:13.480 luup_log:0: 8888B <0x2f403680>