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

Hi

I've tied to get this to work with no luck.

I added a virtual device with the IP to one of my Sons devices and the TCP 1400.

I the added a button, see image, I deleted all tailing spaces.

Nothing happens when i press the button, am I doing anything wrong?

Please login or register to see this attachment.

Link to comment
Share on other sites

  • 0
Guest deraaij
  • Inquirer
  • Hi

    I've tied to get this to work with no luck.

    I added a virtual device with the IP to one of my Sons devices and the TCP 1400.

    I the added a button, see image, I deleted all tailing spaces.

    Nothing happens when i press the button, am I doing anything wrong?

    add 0x0D0x0A0x0D0x0A at the end.

    Link to comment
    Share on other sites

    • 0
    Guest deraaij
  • Inquirer
  • you are sure there are no trailing spaces ? (only enters) and or spaces in front of a line?

    Link to comment
    Share on other sites

    • 0

    Nope nothing seams to work, here is how I'll do it:

    1. Add a virtual device

    Please login or register to see this link.

    2. Add a button

    Please login or register to see this link.

    3. Open sonos and start to play something on speaker 10.6.2.113

    4. Pause the music

    5. Back to HC2 and try the button

    6. Nothing happens

    I have 4 sonos speakers, I also attached the "raw" button input so that you can see that I haven't missed any spaces.

    Do I hav to do something with my Sonos system?

    Please login or register to see this link.

    Link to comment
    Share on other sites

    • 0
    Guest deraaij
  • Inquirer
  • Can you start with a new virtual device? I had some issues in the past with ones were I deleted buttons.

    Link to comment
    Share on other sites

    • 0

    Hello Deraaj and all of you sonos users !

    with newest beta of HC2, I've seen the new field 'main loop'. That would be interesting to poll the volume value in order to update the slider position, but I've no idea on how to proceed... What request is to be sent to a player ?

    Also, I've got different icons for paused/stopped and 'any other cases' (

    Please login or register to see this link.

    ). I'd like to know the state of the player so to update as well the icon. Any hint ?

    Thanx in advance for your reply

    Edit : maybe could we even add in a label field the current music name

    Link to comment
    Share on other sites

    • 0
    Can you start with a new virtual device? I had some issues in the past with ones were I deleted buttons.

    I have done that 10 times.

    Can it be that I'm using the latest beta, 3.560?

    Link to comment
    Share on other sites

    • 0

    Hi Sonos bods,

    Can anyone advise if there is an add in framework for Sonos that can call a web api on key events?

    thanks

    Link to comment
    Share on other sites

    • 0
    Guest deraaij
  • Inquirer
  • Can you start with a new virtual device? I had some issues in the past with ones were I deleted buttons.

    I have done that 10 times.

    Can it be that I'm using the latest beta, 3.560?

    I have the same version and works like a charm.

    [ Added: 2013-09-10, 20:05 ]

    Hi Sonos bods,

    Can anyone advise if there is an add in framework for Sonos that can call a web api on key events?

    thanks

    Yes. you can "SUBSCRIBE" on the url "/MediaRenderer/AVTransport/Event" of your sonos. I have made a python script which fires a scene when my livinigroom zone starts to play.

    Link to comment
    Share on other sites

    • 0
    Yes. you can "SUBSCRIBE" on the url "/MediaRenderer/AVTransport/Event" of your sonos. I have made a python script which fires a scene when my livinigroom zone starts to play.

    __

    thanks will go and investigate

    Link to comment
    Share on other sites

    • 0
    Hello Deraaj and all of you sonos users !

    with newest beta of HC2, I've seen the new field 'main loop'. That would be interesting to poll the volume value in order to update the slider position, but I've no idea on how to proceed... What request is to be sent to a player ?

    Also, I've got different icons for paused/stopped and 'any other cases' (

    Please login or register to see this link.

    ). I'd like to know the state of the player so to update as well the icon. Any hint ?

    Thanx in advance for your reply

    Edit : maybe could we even add in a label field the current music name

    +1. This has been accomplished in Vera, but like lordyorik, i do not know how to proceed

    Please login or register to see this image.

    /emoticons/default_icon_curve.gif" alt=":-/" />

    Link to comment
    Share on other sites

    • 0
    Guest deraaij
  • Inquirer
  • Hello Deraaj and all of you sonos users !

    with newest beta of HC2, I've seen the new field 'main loop'. That would be interesting to poll the volume value in order to update the slider position, but I've no idea on how to proceed... What request is to be sent to a player ?

    Also, I've got different icons for paused/stopped and 'any other cases' (

    Please login or register to see this link.

    ). I'd like to know the state of the player so to update as well the icon. Any hint ?

    Thanx in advance for your reply

    Edit : maybe could we even add in a label field the current music name

    Sorry I am quite busy, but example to get current state of a particular sonos zone:

    Please login or register to see this code.

    for volume:

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0

    Hi Adv.Usr.deraaij

    Thanks for your posts on controlling Sonos via HC2 - really really helpful!

    Your last two examples I can't get to work though on a Virtual device via Lua...

    I'm getting a HTTP 500 Internal Server Error on the GetVolume example. Would there be any way you could point me in the right direction?

    Really appreciate your help!

    Thanks

    Link to comment
    Share on other sites

    • 0
    Guest deraaij
  • Inquirer
  • Hi Adv.Usr.deraaij

    Thanks for your posts on controlling Sonos via HC2 - really really helpful!

    Your last two examples I can't get to work though on a Virtual device via Lua...

    I'm getting a HTTP 500 Internal Server Error on the GetVolume example. Would there be any way you could point me in the right direction?

    Really appreciate your help!

    Thanks

    mhhhm strange I tested i with my virtual device and it works, can you post a screen print of your virtual device button (code)?

    Link to comment
    Share on other sites

    • 0

    Hi Mark,

    Thanks for replying... I've copied the code word for word from your example (for GetVolume) - just replacing with the IP address of my Sonos Playbar (192.168.0.155).

    I've attached the debug output (showing the error)...

    Here's the exact code I'm using:

    Please login or register to see this code.

    Thanks!

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0
    Guest deraaij
  • Inquirer
  • Ok found it. Make sure you delete all the trailing spaces on each line. When you copy paste it it gives you a unwanted space at the end of each line.

    Link to comment
    Share on other sites

    • 0

    Works great! I should have thought of that!!

    Please login or register to see this image.

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

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