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


TUTORIAL - Sonos Remote VD (using node-sonos-api)


Recommended Posts

No clue what happened here.

 

Till yesterday all was working fine, but today when trying to start npm I get the following:

Please login or register to see this code.

Link to comment
Share on other sites

Never mind...

 

Restarted the RPI and all is working fine again!

 

Link to comment
Share on other sites

On 23.1.2017 at 9:16 PM, AutoFrank said:

I included some code above to replace any spaces with a + so you can send a normal sentence and encode and send within the button or scene

 

hope this helps...

-frank

 

Hi Frank,

 

thanks for help. It works now for me but i must use %20 in html code for blanks and can not use + symbols.

 

This example works for me

 

Please login or register to see this code.

Link to comment
Share on other sites

  • Topic Author
  • 8 minutes ago, gobbli said:

     

    Hi Frank,

     

    thanks for help. It works now for me but i must use %20 in html code for blanks and can not use + symbols.

     

    This example works for me

     

    Please login or register to see this code.

     

    Hi @gobbli

     

    Glad its working 

     

    Quick question

    The format I use is /room/say/words/volume but you seem to have a / in the middle of the words to be spoken

     

    response = sonos:GET("/Hobbyraum/say/Hallo%20von%20Sonos/de-DE/40")

    I'm not sure if you know that its not needed

     

    -f

     

     

     

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • Hi All,

     

    I switched over to using AWS Polly TTS and the voice is good bit better.

     

    I have to update the settings.json file on the api to reflect the new TTS service

     

    The format for VoiceRSS is 

    Please login or register to see this code.

     

    The format for AWS Polly is  

    Please login or register to see this code.

     

    I also upgraded the latest api (version": "1.2.6") and between both changes encoding the string by replacing a space with a + is no longer working as it speaks the plus sign so I needed a new encoding solution and this what I'm now using.

     

    Please login or register to see this code.

    AWS Polly also requires the name of the voice before the volume (Amy above)

     

    Link to comment
    Share on other sites

    Hey @AutoFrank, I'm thinking of switching from the kirkoffs vd to your solution.

    To test I tried to get node.js running on my old qnap but it wouldn't work.. So before I pull my hair out getting this to work on one of my old R-pi's, it there still the same delay as in kirkoffs vd when running a tts?

     

    Jim

    Link to comment
    Share on other sites

  • Topic Author
  • On 1/27/2017 at 7:31 PM, gobbli said:

    ok frank, now i know it ;-)

     

    Hi @jimicr

    The delay is about 1-2 seconds for me and I think it works very well

    I was using voiceRSS and recently switched to AWS Polly. The performance is the same but polly has more natural sounding voices.

     

    If you want to just get it up and running quickly on a pi, I suggest the following approach (15 mins)

     

    Use the sonos-api precompiled rpi image at 

    Please login or register to see this link.

     (apply to blank sd card)

    when you login over SSH (with something like putty) the password is root

    Map a network drive or Start Run to \\<IP of PI>\flash

    click apps folder and you'll see the sonos-http-api folder

    Get an API from VoiceRSS and create a settings.json file (details in the post) and drop it into the sonos-http-api folder 

    Reboot the Pi and that's it - test through browser with something like http://<ip-of-Pi:5005/<playername>/Say/Hello

     

    If you want to upgrade to the latest api release

    Download the latest zip from 

    Please login or register to see this link.

     (green button on right)

    In the flash folder rename the sonos-http-api to -old

    Rename what you downloaded to to sonos-http-api

    Drop in your settings.json file

    SSH into the Pi - login = root

    cd /flash/apps

    cd sonos-http-api

    npm install --production

    when finished reboot

     

     

    **I also added this information to the first post**

     

    hope this helps

    -f

     

     

     

     

     

     

    Edited by AutoFrank
    Link to comment
    Share on other sites

  • Topic Author
  • 5 minutes ago, jimicr said:

    Looks easy enough, will try as soon as possible!!

    thanks @AutoFrank

     

     

    @jimicr

    No worries, give me a shout if you get stuck

    TBH - for me it transformed the level of control I have with my players and 90% of our use is now automated:-)

     

    Link to comment
    Share on other sites

    Any idea why my VD stops updating? Everything seems to be working fine and I have full control, but things like volume, track, etc just stop updating in the VD but as soon as I hit the "save" icon it updates. 

    Link to comment
    Share on other sites

  • Topic Author
  • 34 minutes ago, Desmo said:

    Any idea why my VD stops updating? Everything seems to be working fine and I have full control, but things like volume, track, etc just stop updating in the VD but as soon as I hit the "save" icon it updates. 

     

    Hi @Desmo

    Could you post the main loop code or export the vd and attach and I can take a look ...

    Have you verified that the device that is running the api is working all the time.

    Link to comment
    Share on other sites

    Main loop...


    local device = fibaro:getSelfId();
    local zonename = fibaro:getName(device);
    local ipaddress = fibaro:getValue(device, "IPAddress");
    local port = fibaro:getValue(device, "TCPPort");
    sonos = Net.FHttp(ipaddress, port);

    response = sonos:GET("/Nursery/state");
    jsonTable = json.decode(response);

    fibaro:debug(jsonTable.volume)
    fibaro:debug(jsonTable.playbackState)
    fibaro:debug(jsonTable.currentTrack.title)

    fibaro:call(device,"setProperty","ui.lblState.value", jsonTable.playbackState);
    fibaro:call(device,"setProperty","ui.lblVol.value", jsonTable.volume);
    fibaro:call(device,"setProperty","ui.lblTitle.value", jsonTable.currentTrack.title);
    fibaro:log(jsonTable.playbackState)

    fibaro:setGlobal("Nursery_Sonos", jsonTable.playbackState);

     

    I put some debug lines in and they always report corrcectly, it's just the lines in the VD update for a while (been working fine for the last hour since hitting save) but then just stop updating.

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, Desmo said:

    Main loop...


    local device = fibaro:getSelfId();
    local zonename = fibaro:getName(device);
    local ipaddress = fibaro:getValue(device, "IPAddress");
    local port = fibaro:getValue(device, "TCPPort");
    sonos = Net.FHttp(ipaddress, port);

    response = sonos:GET("/Nursery/state");
    jsonTable = json.decode(response);

    fibaro:debug(jsonTable.volume)
    fibaro:debug(jsonTable.playbackState)
    fibaro:debug(jsonTable.currentTrack.title)

    fibaro:call(device,"setProperty","ui.lblState.value", jsonTable.playbackState);
    fibaro:call(device,"setProperty","ui.lblVol.value", jsonTable.volume);
    fibaro:call(device,"setProperty","ui.lblTitle.value", jsonTable.currentTrack.title);
    fibaro:log(jsonTable.playbackState)

    fibaro:setGlobal("Nursery_Sonos", jsonTable.playbackState);

     

    I put some debug lines in and they always report corrcectly, it's just the lines in the VD update for a while (been working fine for the last hour since hitting save) but then just stop updating.

     

    Hi @Desmo

     

    I have it working here for the last 15 mins and will keep it running for the next while but we have multiple zones running all day and never saw this issue

    Any error in the vd main loop will cause the updating to stop .

     

    The only thing I have seen is that depending on what you're listening to the 'title' can be blank but I've never seen it stop the main loop 

    Are you listening to the same music during in this time ?

     

    Two things to try when it stops next 

    click the debug button on the main loop and see if there are any errors there, it may help pinpoint the issue.

    drop http://<ip-of-Pi>:5005/Nursery/State in to a browser and see if the usual json formatted data is there (this will tell you if the api is still running)

     

    Unrelated but ...

    I listen to most internet radio and don't use currentTrack.title much as its just garbage, I tend to use currentTrack.artist more

     

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • Updated first post with information on getting the api running on a pi in 15 mins or less

     

    Link to comment
    Share on other sites

    2 hours ago, AutoFrank said:

    Two things to try when it stops next 

    click the debug button on the main loop and see if there are any errors there, it may help pinpoint the issue.

    drop http://<ip-of-Pi>:5005/Nursery/State in to a browser and see if the usual json formatted data is there (this will tell you if the api is still running)

     

    OK...just taken a look as it stopped updating again. Taking a look at the Jason data direct is fine, it's all showing as it should be. When I debug the VD it's stopped updating itself with no errors. I've just hit "save" again and it starts updating again instantly.

     

    I'm going to keep an eye on how long it runs for to see if it's consistent in time run before it stops. I'm getting the same problem with all of my Sonos speakers, not just this one. I wonder if it's a bigger system wide problem. 

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, Desmo said:

    OK...just taken a look as it stopped updating again. Taking a look at the Jason data direct is fine, it's all showing as it should be. When I debug the VD it's stopped updating itself with no errors. I've just hit "save" again and it starts updating again instantly.

     

    I'm going to keep an eye on how long it runs for to see if it's consistent in time run before it stops. I'm getting the same problem with all of my Sonos speakers, not just this one. I wonder if it's a bigger system wide problem. 

    Hi @Desmo

     

    That's very odd alright.

    Do they all stop together ? 

    I have 14 sonos players and I have a vd that monitors them all and it's been running for months updating volume and status every second and I've never day it freeze or stop.

    I assume you have restarted the pi?

    Have you tried to reinstall the api?

    I wonder is something on your HC2 impacting the VD?. You could try checking cpu/mem when it stops ?

     

    Could you export the VD and let me know how long it m takes to stop.

    I think I posted the code for my vd that monitors all my zones, if not I could send it on and you could install that and see if that also stops updating? 

     

     

    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
    Reply to this topic...

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