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

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]

Link to comment
Share on other sites

Recommended Posts

  • 0

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? 

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0

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=";-)" />

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

  • 0

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..

Link to comment
Share on other sites

  • 0

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
Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0

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.

Link to comment
Share on other sites

  • 0

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).

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0

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

Link to comment
Share on other sites

  • 0
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:

 

 

Link to comment
Share on other sites

  • -1

For me the problem is that I don't seem to be able to import VD, not only this one, but any.

When i upload it I onle get a HTTP 500 error, does anyone know what i'm doing wrong?

Link to comment
Share on other sites

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...