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

Hello, thank you for this great topic. It helps a lot. But I still have problems playing a radio station via TCP.  I did (several times now) steps mentioned above. If I got it right you first have to press the button with the radio station and after that the play button. But nothing happens. Sonos keeps playing current song or starts playing the current song in the playlist. I also tested the code with 0x0D0x0A0x0D0x0A at the end - no luck. It would be very great if someone could help me out here, please. At my HC2 there is Version 4.040 running

Hello

 

I made it this way : copy all addresses from RADIOLOG and made .m3u  playlist file - and then put link to this file - works ok.

playFile("//192.168.2.155/music/3.m3u", 30);

 

But I have another issue - MP3 plays only for 30 sec and stops autmaticly - anyone knows why?

  • 0
Guest SPyRoX
  • Inquirer
  • Posted

    amilanov and others,

    If you are using Krikroff's virtual device, you can use the following code in a scene to change the volume of the sonos player:

     

    Please login or register to see this code.

    Happy Automating,

    Adam Bewsher

     

    Is there a way that the volume is like +5 or -5 instead of setting the volume at a specific number?

    • 0
    Posted

    If someone could be so kind as to provide me a step by step account of how i can get text to speak to work on my sonos from the very beginning i would be forever greatful being a complete novice to all of this - I am learning but its an up hill struggle

    Many Thanks!!!

    • 0
    Posted

    Hello

    I made it this way : copy all addresses from RADIOLOG and made .m3u  playlist file - and then put link to this file - works ok.

    playFile("//192.168.2.155/music/3.m3u", 30);

     

    Hi, thank you for the tip. But I think I am still doing something wrong. The output of my radiolog is as following:

     

    17826 playlist

    Please login or register to see this link.

    17826 stream x-rincon-mp3radio://ibizaglobalradio.streaming-pro.com:8024/
    17826 stream x-rincon-mp3radio://mobile.ibizaglobalradio.streaming-pro.com:8026/
    17826 stream x-rincon-mp3radio://37.59.254.28:8024/
     

    So I grabbed the 4 links and made an m3u file with the following content:

     

    #EXTM3U
    #EXTINF:-1,IBIZAGLOBAL - 

    Please login or register to see this link.

    #EXTINF:-1, IBIZAGLOBAL - 
    x-rincon-mp3radio://ibizaglobalradio.streaming-pro.com:8024/
    #EXTINF:-1, IBIZAGLOBAL - 
    x-rincon-mp3radio://mobile.ibizaglobalradio.streaming-pro.com:8026/
    #EXTINF:-1, IBIZAGLOBAL - 
    x-rincon-mp3radio://37.59.254.28:8024/
     
    But when I press the button on my vd nothing happens. Can you please help me out, thanks!
     
    ANOTHER TOPIC:

     

    But I have another issue - MP3 plays only for 30 sec and stops autmaticly - anyone knows why?

     

    I had the same problem. I solved it this way. I commented out the "stop" funktion and now the file from my NAS plays till the end. But I prefere listening to internet radio stations.

    Please login or register to see this code.

    • 0
    Posted

    The VD works fine, it shows the status of the speaker ( volume, station etc ) . The problem is that i can not change anything, i use tcp 1400, is this right ) . Wow can i define witch radio station ? 

     

    Thx, 

     

    Rolli

    • 0
    Posted

    Thank you for the awesome plugins

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> I am looking forward to integrate Sonos to my smart home.

     

    However, I have the same problems as rolli79. When controlling the Sonos units from the Sonos app, I can see status changes in the Fibaro virtual device (e.g. State: Playing). However, I can't control the player - it does not respond to e.g. pause, volume changes, favorite radio stations. It says that the commands were sent (e.g. "The pause command was sent").

     

    I have tried to remove the devices (had both the normal device and TTS), restart HC2, and re-add only the Sonos Player virtual device, with no luck.

     

    Plugin version 0.0.8 from 

    Please login or register to see this link.

    .

    Fibaro HC2 4.049

    Sonos Controller for Mac 5.4

    Sonos PLAYBAR: version 5.4 (build 29591030)

     

    Edit: I added the global variables as explained

    Please login or register to see this link.

    , and now it seems to work! Ideally, a README or similar should be included explaining the necessities, as this thread is growing big

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    • 0
    Posted

    sonos can play folder music ?? muti zone in sonos with fibaro controler???

    • 0
    Posted

    pls, sonos can group zone and play folder music on HC2, help me pls...thank you

    • 0
    Posted

    Help me please.

     

    TTS google stopped work, said Unable to play 'translate+tts?......' station not found.

     

    Before work good, my network IP was blocked google and now google set captcha.

     

    How resolve it? Before my HC2 and SONOS talk good. And now problem. 

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" /> 

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" /> 

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" />

     

    My code:

    Please login or register to see this code.

    Can you help me give me code for play url http:// file.mp3 , I can record it and ask from my server not from google TTS link.

     

    But I don't now what's Lua code correct please. <CurrentURI>x-rincon-mp3radio: ?? change to ask URL? It's possible please? Thank you.

    • 0
    Guest matie
  • Inquirer
  • Posted

    Hi,

     

    Tip for those struggling with sonos and having a raspberry Pi laying around: 

    Please login or register to see this link.

     

    This makes it a lot easier integrating your sonos without the need to implement it all in lua. Just fire a webservice call.

    And you are able to check the status of all of your sonos players i.e. what song is being played, is mute enabled etc. etc.

     

    All commands:

     

    • play
    • pause
    • playpause (toggles playing state)
    • volume (parameter is absolute or relative volume. Prefix +/- indicates relative volume)
    • groupVolume (parameter is absolute or relative volume. Prefix +/- indicates relative volume)
    • mute / unmute
    • groupMute / groupUnmute
    • seek (parameter is queue index)
    • trackseek (parameter is in seconds, 60 for 1:00, 120 for 2:00 etc)
    • next
    • previous
    • state (will return a json-representation of the current state of player)
    • favorite
    • playlist
    • lockvolumes / unlockvolumes (experimental, will enforce the volume that was selected when locking!)
    • repeat (on/off)
    • shuffle (on/off)
    • crossfade (on/off)
    • pauseall (with optional timeout in minutes)
    • resumeall (will resume the ones that was pause on the pauseall call. Useful for doorbell, phone calls, etc. Optional timeout)
    • say (TTS)
    • clearqueue
    • 0
    Posted

    Help me please.

     

    TTS google stopped work, said Unable to play 'translate+tts?......' station not found.

     

    Before work good, my network IP was blocked google and now google set captcha.

     

    How resolve it? Before my HC2 and SONOS talk good. And now problem. 

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" /> 

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" /> 

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" />

     

    My code:

    Please login or register to see this code.

    Can you help me give me code for play url http:// file.mp3 , I can record it and ask from my server not from google TTS link.

     

    But I don't now what's Lua code correct please. <CurrentURI>x-rincon-mp3radio: ?? change to ask URL? It's possible please? Thank you.

     

    I have the same issue. TTS Stopped working. Anybody has/knows a solution?

    • 0
    Posted

    i found this somewhere:

     

    Seems google changed api a bit.

     

    search for this line in the code:

    x-rincon-mp3radio://translate.google.com/translate_tts?tl=".. lng .. "&a" .. "mp;q=" .. urlencode(message) .. "</CurrentURI>,<CurrentURIMetaData></CurrentURIMetaData>", -- callback (options)

     

    add client=t after translate_tts in code so it looks like this:

     

    //translate.google.com/translate_tts?client=t&tl=".. lng

     

    it should work.

    • 0
    Posted

    Yup it works... 

     

    thx

    Please login or register to see this code.

    • 0
    Posted
    Here I have done something that is possibly interesting. Especially for german-speaking users.
     
    It is a virtual device with radio, music and TTS elements which are controlled by the predefined variables. In addition, I describe an application with motion detector and radio streaming.
     

    Please login or register to see this link.

     
    Thanks to...
    --> Jean-Christophe Vermandé
    --> stevenvd
    ...for the basics.
    • 0
    Posted

    I have a question. Is it already possible to set the source of the Sonos? I play with TTS if somebody is at the front-door, but if I am watching TV, the TTS works, but I don't go back. I don't see any source in this VD?

    • 0
    Posted

    I am struggling to get TTS to work. If I debug I get
     
    [DEBUG] 21:30:07: unMute sent[/size]
    [DEBUG] 21:30:07: Volume set: 80[/size]
    [DEBUG] 21:30:07: tts: Hello from your smart house[/size]
    [DEBUG] 21:30:07: play sent[/size]
    [DEBUG] 21:30:07: TRANSITIONING[/size]
    [DEBUG] 21:30:12: TRANSITIONING[/size]
    [DEBUG] 21:30:17: TRANSITIONING[/size]
    [DEBUG] 21:30:22: STOPPED[/size]
    [DEBUG] 21:30:27: STOPPED[/size]
    [DEBUG] 21:30:30: stop sent[/size]
    [DEBUG] 21:30:30: Volume set: 40[/size]
     
     
    and also noticed on the sonos app I get my text message with the translate text in it.

     

    Any help much appreciated

    • 0
    Posted

    Oh and it's line 1319 so you don't waste half of September looking for the string

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    • 0
    Posted

    Hi all,

    I have Sonos TTS running to be notified when my washing machine is ready (via power meter... see different thread). Actually this is working quite well, but I am having a slight issue:

    1) When the TTS command has been executed the related speaker loses its Group for some reason.

    2) When the TTS command has been executed, the TTS was the Last "media" that has been played, so actually the play button on the Sonos is not working anymore. Here I would like to have a solution that checks, which Media has been played before (e.g. radio station) and sets the related media after the TTS has been pushed.
    Is that possible?

     

    cheers

    joystick

    • 0
    Posted

    Dear all, 
     
     
    I do not know how to solve my problem.
     
    I want to play a radio station
    I created a virtal device and several buttons. I can play, stop the sonos box. But I am not able to change the radio station. 
     
    I used to following orignal code:

    Please login or register to see this code.

    I have followed the instruction: 

    1.) Play correct radio station on a zone. 
    2.) Surf to

    Please login or register to see this link.

    >:1400/status/radiolog 
    3.) Take the correct url, and replace the one in the example code

     

    This was displayed:

    Timestamp Type URI 5557418 playlist

    Please login or register to see this link.

    5557419 stream mms://apasf.apa.at/OE3_Live_Audio 5557419 stream rtsp://apasf.apa.at/OE3_Live_Audio 5557419 stream x-rincon-mp3radio://194.232.200.156:8000 5557419 stream x-rincon-mp3radio://mp3stream7.apasf.apa.at:8000

    I thought to replace the radiostation information in the orignial code with this: x-rincon-mp3radio://194.232.200.156:8000

     

    But without success.

     

    May someone can help me and can provide me with the right code (including the right content lenght value.

     

    kind regards

    Andreas

     

    • 0
    Posted

    Hi there,

     

    I have tried some of the lua codes to make tts work on my sonos box. But stil no results.

     

    does someone has some sample codes ? 

     

    Thanks

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