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
Guest deraaij
  • Inquirer
  • Posted

    With this code you can make scenes talk via son0s:

    Please login or register to see this code.

    • 0
    Guest deraaij
  • Inquirer
  • Posted

    Hi all,

    I have been playing around and found out that it also works when just using TCP commands. Also the volumeslider works. If you add commands be aware to change the content Length in line with the length of the body message.

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

    EDIT: Added way to get your own radio station.

    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

    Please login or register to see this code.

    Example Text-2-Speech using TCP:

    Please login or register to see this code.

    Remark: adjust lenght accoring to Soap body. And play needs to be initiated to actual play the text.

    Example play song from network with TCP:

    Please login or register to see this code.

    Remark: adjust lenght accoring to Soap body. And play needs to be initiated to actual play the song.

    Example radio station via TCP:

    Please login or register to see this code.

    Remark: adjust lenght accoring to Soap body. And play needs to be initiated to actual play radio.

    Ok, to get the correct url for your radio station do the following:

    1.) Play correct radio station on a zone.

    2.) Surf to http://<>:1400/status/radiolog

    3.) Take the correct url, and replace the one in the example code (

    Please login or register to see this code.

    ).

    Ungroup zone option 1

    Please login or register to see this code.

    Ungroup zone option 2

    This one proved to be a bit more stable for some users.

    Please login or register to see this code.

    Group to zone

    First check :1400/status/topology the UUID of your main zone, e.g: RINCON_000E58226B1601400

    Please login or register to see this code.

    Be aware that if you copy and paste the TCP variant it add's some spaces which you have to delete manually. After save of the radio variants html encoded text is changed to normal chars if you make a change and save it again it will not work.

    Regards,

    Mark

    • 0
    Guest ruud.coppens
  • Inquirer
  • Posted
    I have been playing around and found out that it also works when just using TCP commands. Also the volumeslider works. If you add commands be aware to change the content Length in line with the length of the body message.

    Hi Mark,

    Can you give more information on how to use the TCP commands?

    In LUA i can control Sonos but have the same issue as you discribe earlier.

    After adding a virtual device with ip number x.x.x.x and TCP port 1400 and a button with one of the tcp commands doesn't give any result.

    Thanks a lot!

    Ruud

    • 0
    Guest deraaij
  • Inquirer
  • Posted
    I have been playing around and found out that it also works when just using TCP commands. Also the volumeslider works. If you add commands be aware to change the content Length in line with the length of the body message.

    Hi Mark,

    Can you give more information on how to use the TCP commands?

    In LUA i can control Sonos but have the same issue as you discribe earlier.

    After adding a virtual device with ip number x.x.x.x and TCP port 1400 and a button with one of the tcp commands doesn't give any result.

    Thanks a lot!

    Ruud

    Hi Ruud,

    Be aware that if you copy & paste it adds some unwanted trailing spaces. If you remove those it will work

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" />

    Regards,

    Mark

    • 0
    Posted

    Thank you!

    • 0
    Guest deraaij
  • Inquirer
  • Posted
    Thank you!

    You are welcome!

    This weekend I finished a python script which receives an update from the sonos as soon as something changes (Paused --> playing et cetera). I will post the info shortly.

    I use it to set my receiver to on and the correct input when someones hits play on the particular zone.

    Regards,

    Mark

    • 0
    Guest deraaij
  • Inquirer
  • Posted

    Hi I got some question on playing song and/or radio. So i want to share some more examples:

    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 Text-2-Speech using TCP:

    Please login or register to see this code.

    Remark: adjust lenght accoring to Soap body. And play needs to be initiated to actual play the text.

    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 play song from network with TCP:

    Please login or register to see this code.

    Remark: adjust lenght accoring to Soap body. And play needs to be initiated to actual play the song.

    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.

    Example radio station via TCP:

    Please login or register to see this code.

    Remark: adjust lenght accoring to Soap body. And play needs to be initiated to actual play radio.

    Be aware that if you copy and paste the TCP variant it add's some spaces which you have to delete manually. After save of the radio variants html encoded text is changed to normal chars if you make a change and save it again it will not work.

    In case of questions let me know.

    Regards,

    Mark

    • 0
    Guest dsilletti
  • Inquirer
  • Posted

    Wonderful job deraaij!!!

    with the control and text2speech it's time for me to buy some Sonos 3 for my rooms.

    What about the sound quality? is really good?

    I was thinking to buy Bose, but now I think I wll buy the Sonos system.

    Regards

    • 0
    Posted

    Thank you so much! This is great!! + voice function! Absoluteley amazing!!!

    If you come up with more commands/functions please let us know

    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
    Guest deraaij
  • Inquirer
  • Posted
    Wonderful job deraaij!!!

    with the control and text2speech it's time for me to buy some Sonos 3 for my rooms.

    What about the sound quality? is really good?

    I was thinking to buy Bose, but now I think I wll buy the Sonos system.

    Regards

    Your welcome!

    It depends on the size of the room which sonos is the best option. I have all the types and I am very happy with them. I would only not recommend the play:3 for a big room.

    Thank you so much! This is great!! + voice function! Absoluteley amazing!!!

    If you come up with more commands/functions please let us know

    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" />

    Your welcome! I hope I have time to include art when playing a radio station.

    I also have a python script which can trigger a scene when a sonos starts playing. If some one is interested I will post it.

    Regards,

    Mark

    • 0
    Guest ygh
  • Inquirer
  • Posted

    Hi,

    Very interesting !

    Can you advise on what is possible to do with V1.045 using http within a virtual device, please

    Thanks,

    YG

    www.ghafoor.org

    • 0
    Guest deraaij
  • Inquirer
  • Posted
    Hi,

    Very interesting !

    Can you advise on what is possible to do with V1.045 using http within a virtual device, please

    Thanks,

    YG

    www.ghafoor.org

    You can use the TCP versions. Those work both in the beta and the stable version. Lua is only available in the beta release.

    Regards,

    Mark

    • 0
    Guest ygh
  • Inquirer
  • Posted

    Thanks - will try this week-end !

    • 0
    Posted

    Your welcome! I hope I have time to include art when playing a radio station.

    I also have a python script which can trigger a scene when a sonos starts playing. If some one is interested I will post it.

    Regards,

    Mark

    Thank you:), I am definately interested, but Im not that familiar with python scripting. Hope you can explain a little... Perhaps give a step by step guide or link to necessary documentation.

    Thanks again for your support.

    • 0
    Guest deraaij
  • Inquirer
  • Posted

    Hi am not a real programmer but it works. You need python and the twisted library:

    Please login or register to see this code.

    Obviously it will work in any other program language.

    Regards,

    Mark

    • 0
    Posted

    Thank you! Looks interesting!

    I was wondering if you have any solution to group all zones in house. In case of a fire alarm I want all zones to play a message on repeat. Now I have the solution for message and repeat (see below). But is there any command that I can group all zones??

    "Repeat all" command:

    POST /MediaRenderer/AVTransport/Control HTTP/1.1

    Content-Length: 308

    SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#SetPlayMode"

    0

    REPEAT_ALL

    0x0D0x0A0x0D0x0A

    • 0
    Guest deraaij
  • Inquirer
  • Posted
    Thank you! Looks interesting!

    I was wondering if you have any solution to group all zones in house. In case of a fire alarm I want all zones to play a message on repeat. Now I have the solution for message and repeat (see below). But is there any command that I can group all zones??

    "Repeat all" command:

    POST /MediaRenderer/AVTransport/Control HTTP/1.1

    Content-Length: 308

    SOAPACTION: "urn:schemas-upnp-org:service:AVTransport:1#SetPlayMode"

    0

    REPEAT_ALL

    0x0D0x0A0x0D0x0A

    Hi I had a look for you:

    First check :1400/status/topology the UUID of your main zone, e.g: RINCON_000E58226B1601400.

    Second step is to make sure no zone is grouped (per ip adress):

    Please login or register to see this code.

    Third step add members per IP Adress to one main zone (using the RINCON ID from step 1):

    Please login or register to see this code.

    Of course you could use LUA to loop through a list of IP adresses, but you have all the info to continue

    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" />

    Regards,

    Mark

    • 0
    Posted

    Thanks, this is awesome!!

    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" /> Great job!

    • 0
    Guest deraaij
  • Inquirer
  • Posted
    Thanks, this is awesome!!

    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" /> Great job!

    You're welcome!

    • 0
    Guest deraaij
  • Inquirer
  • Posted

    You can also ungroup a zone by:

    Please login or register to see this code.

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