Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 3

Sonos - Virtual Device


Guest deraaij

Question

Guest deraaij
Posted

Update: Please use TCP as of version 3.x as os.execute has been depreciated. As soon as we are able to have custom headers I will update the LUA code.

Hi all,

For those who are interested I made a Virtual Device based on the new LUA feature (inspired on lua code for MIOS) which can control a sonos device. It uses curl but will change it when the http api is documented. Change the IP address accruing to your needs.

EDIT: Added additional comments from other post which I posted in this thread.

EDIT: Changed req.lua --> /tmp/req.lua which works with beta 3.423 & 3.424

Play

Please login or register to see this code.

Stop

Please login or register to see this code.

Pause

Please login or register to see this code.

Previous

Please login or register to see this code.

Next

Please login or register to see this code.

Mute

Please login or register to see this code.

UnMute

Please login or register to see this code.

Volume – Not Working yet because we do not get the value off: _sliderValue_ @fibaro how does this work with Lua?

Please login or register to see this code.

Example Text-2-Speech using LUA in a scene:

Please login or register to see this code.

Remark: Play is initiated with the last statement to actual play the text (change it accordingly).

Example play song from network with LUA:

Please login or register to see this code.

Remark: Play is initiated with the last statement to actual play the song (change it accordingly).

Example radio station via LUA:

Please login or register to see this code.

Remark: Play is initiated with the last statement to actual play radio (change it accordingly). For now only the radio name is set.

Regards,

Mark[/b]

Recommended Posts

  • 0
Posted

Hi

Topics with Sonos and Fibaro were started years ago, code works nice, and  is still developed.

But it use common UPnP protocol, available at many other devices.

I tried to find any side threads, how to update Sonos code to handle other similar devices, ex. Networked Amplifiers... but I did not found a lot.

I did some testst with my Denon X2000, and it is succesfull (!)

Unfortunately I still have problems with TTS - Mp3 files generated by Google are not played by Denon (even if you download the MP3 file and try to play it from local sources).

I did succesfull tests with TTS files converted to higher kHz and 2ch, placed on my webserver (so available via HTTP URL, without UPnP server).

I had problems with internet radios, I managed to start plaback only these, which are HTTP and with mp3 file as a source. It looks as Denon limitation for UPnP.

 

Maybe is it worth to stard some new threads here and develop Sonos functionality with other devices. UPnP DMR is available at all networked amplifiers, at all Smart TVsets, most of networked MediaPlayers has it...

  • 0
Posted

First of all, really nice job done!

 

Now for my noob question 

Please login or register to see this image.

/emoticons/default_icon_razz.gif" alt=":-P" />: can the TTS device after playing the TTS (or mp3) set the sonos back to continue what it was playing before the TTS interrupted? 

  • 0
Posted

First of all, really nice job done!

 

Now for my noob question 

Please login or register to see this image.

/emoticons/default_icon_razz.gif" alt=":-P" />: can the TTS device after playing the TTS (or mp3) set the sonos back to continue what it was playing before the TTS interrupted?

I'm also very interested in this feature.

Regards,

Robert

  • 0
Posted

I'm also very interested in this feature.

Regards,

Robert

 

Same here

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

  • 0
Posted

that would be awesome

  • 0
Posted

+1, but nobody has a solution yet..

  • 0
Posted

If Sonos or other UPnP device plays something controlled by UPnP, you can use UPnP commands to retrieve information, than start playback after TTS. But if Sonos actually plays something controlled localy (ex. from USB), than it can be a problem.

You can start any UPnP software at the PC (for example small and simple upplay program), and use it with Wireshark to scan UPnP commands and response. Programs as uppplay asks UPnP renderer device for status every second.

I did it with Denon AVR, and when Denon was controlled via UPnP, even from other device, I was able to see status and references of played file. But when I switched Denon to other source, it was not possible to use UPnP to check and control it. UPnP is not for that. Sonos plugin base on UPnP commands.

So I think it is possible to solve it, and have continuous play after TTS, but it would work in limited cases, can be also problem with playlist (or longer playback queue) etc. I think there is a chance that it would work with internet radio.

  • 0
Posted

Hey there,

 

looks like all works perfect but i have a problem with my alarm system with the tts workaround.

 

I have a .mp3 alarm file that last for 3 Minutes.

 

My problem is that the file get played from both sonos players, but after 30 seconds it stops. Is this a limit for the tts workaround?

 

So i was thinking it just allows 30 seconds so i just tried to do a while and play the sound again. The problem is that it does just play the sound on one speaker and it ignores the others. Again after 30 seconds it happens that they switch sometimes and so on so it does not work as i want.

Please login or register to see this code.

I really hope someone can help me here..

  • 0
Posted

Hi,

 
So still no solution for the Sonos and TTS?
 
In parallell im looking for a solution running a local TTS service on my osx server. Still running Krikroffs VD but using a local TTS instead of google.
But its not working... Any guidance?
 
I run the program M2S on my OSX server that response to HTTP requests like "

Please login or register to see this link.

Rocks"
The request works running the request in a browser, the TTS comes out just fine.
 
I tried adjusting the Krikroff Virtual device with the proper URL like below but still get a return 500 on my HTTP request.
 
Tested change of VD (line 1320)
 
"<InstanceID>0</InstanceID><CurrentURI>x-rincon-mp3radio://10.0.1.10:8081/tts/?voice=Alex&text="..(urlEncode(message or "") or "message").."</CurrentURI><CurrentURIMetaData>"..Sonos:createMetaData("TSS by Google...").."</CurrentURIMetaData>",
      
Any pruposals?
 
Kristian
  • 0
Posted

Hey there,

 

looks like all works perfect but i have a problem with my alarm system with the tts workaround.

 

I have a .mp3 alarm file that last for 3 Minutes.

 

My problem is that the file get played from both sonos players, but after 30 seconds it stops. Is this a limit for the tts workaround?

 

So i was thinking it just allows 30 seconds so i just tried to do a while and play the sound again. The problem is that it does just play the sound on one speaker and it ignores the others. Again after 30 seconds it happens that they switch sometimes and so on so it does not work as i want.

Please login or register to see this code.

I really hope someone can help me here..

Hello,

 

In the play function change the value off 10 in a higher value.

Now each value is arond 2 second so a value of 10 is around 20 seconds.

If you need three minutes you have to change this value to 180/2= 90 or a little less.

 

Also you can comment out the stop function.

 

 

while (currentTransportState == "PLAYING") do

          if (i > 10) then break end;

          getTransportState();

          fibaro:debug(currentTransportState);

          fibaro:sleep(2000);

          i = i + 1;

        end

  • 0
Posted

Hello,

 

In the play function change the value off 10 in a higher value.

Now each value is arond 2 second so a value of 10 is around 20 seconds.

If you need three minutes you have to change this value to 180/2= 90 or a little less.

 

Also you can comment out the stop function.

 

 

while (currentTransportState == "PLAYING") do

          if (i > 10) then break end;

          getTransportState();

          fibaro:debug(currentTransportState);

          fibaro:sleep(2000);

          i = i + 1;

        end

this is brilliant and works perfectly well.

both methods tested and working.

  • 0
Posted

Has anything been looked at for the Sonos Connect?  I am using the Fibaro HC2 plugin but it has limited functionality, such as being able to choose music source.  I am new to Fibaro (installed Monday).

  • 0
Posted

See

Please login or register to see this link.

  • 0
Posted

Hello robotica,

 

have you've found a solution to playing Sonos Playlists or favourites yet?

 

Still can't figure that out by myself.

 

Best

Markus

  • 0
Posted

hy all, Mark thx you for thoses soap code

 

since HCL dont use Lua VD, and with your help i manage to make sonos run.

 

i would like to know how do you manage those code, play, pause etc. cause actually i am trying to make this works with a Squeezebox .

 

thx

  • 0
Posted

Hello

Is there any chance to play a SONOS PLAYLIST?

 

greetings

robert

  • 0
Posted
10 hours ago, Cannon_82 said:

Hello

Is there any chance to play a SONOS PLAYLIST?

 

greetings

robert

 

at the moment you need to use the sonos node api. which is installed on the pi

you can then use a VD to play the playlist.

see this excellent tutoarial here for more info:

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...