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

  • Topic Author
  • Just now, Bezan said:

    @AutoFrank, thanks! Now it is working.

    Where can I get latest version of this VD? Or no more changes are in next versions? :)

     

    @Bezan

     

    There is really no one or latest version, these are more examples as generally a user will need to customise for API IP address and port, room names, radio favorites, use of presets, and many more possibilities.

    In terms of the basics, the json data for status, artist, title and volume is good

     

     

    Link to comment
    Share on other sites

    • 2 weeks later...

    As all setup is ready now I`m wondering if you guys can share use cases for Sonos + Fibaro (+Alexa).

    Can you share ideas/scenes which can be widely used by more users?

     

    Right now I`m thinking about:

    1. Use Alexa to trigger scene changing soem global variable like "Guest state". Sonos can reply with "Guest state activated".

    2. Our washing-mashine is very "shy" and there is only one "beep" when finished. I`m planning to buy Wall Plug and when detected no power use for X minutes assume washing is over and say "Washing is over. Please open doors :)"

     

     

     

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, Bezan said:

    Our washing-mashine is very "shy" and there is only one "beep" when finished. I`m planning to buy Wall Plug and when detected no power use for X minutes assume washing is over and say "Washing is over. Please open doors :)"

    Hi @Bezan @sankotronic has a appliance monitoring scene that would do the monitoring, you would then just have to add the announcements part

    1 hour ago, Bezan said:

    Use Alexa to trigger scene changing soem global variable like "Guest state". Sonos can reply with "Guest state activated".

    alexa is a whole other game and I'm only just starting on this myself. I've chose to use the HA bridge as it offers me a little more flexibility :-)  There is a good thread on setting this up from @morpheus75

    You can run the HA bridge on the same pi as the sonos-api if you choose this route

    If you choose to use the native fibaro skill you will find it more difficult as this only recognises block scenes and not lua scene.

     

    With alexa you can only say Turn on, turn off and set level so you;ll need to be be creative

    so in your example you would say Turn on Guest Mode, Turn off Guest Mode

    you probably already have a vd to enable / disable guest mode

    You would set up the two vd button presses (enable/disable) to a Guest Mode bridge announcement/device in the HA Bridge and when you say Turn on Guest Mode it'll press the enable button on the VD and Turn Off Guest Mode would press the other button....

     

    as I said I'm just starting down that road but some people on the forum have more experience but that's how I see it working ...

     

     

    Edited by AutoFrank
    Link to comment
    Share on other sites

  • Topic Author
  • 10 minutes ago, RubberDuck said:

    Hi,

     

    is there a possability to use AppleMusic in the Favorites?! For example Playlists?!

     

    @RubberDuck

     

    I don't have apple music but this is what the api readme says 

     

    Please login or register to see this code.

    ... from 

    Please login or register to see this link.

     

    Link to comment
    Share on other sites

    Okay, I must look what I must do there :)

     

    Another Question. You have written that you have an good Morning / good Night butto.

     

    How you have done this?!


    This sounds very interesting :)

    On 1/28/2017 at 6:21 PM, AutoFrank said:

    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)

     

     

    Hi, when I want to use AWS Polly. I must open an Account -> After that I must configure the settngs.json!!?

     

    And you wirte you have TTS Presets?! So you have an VD for that?! Can you publish it, or not?! I would try this then :)

     

    Link to comment
    Share on other sites

  • Topic Author
  •  

     

    15 minutes ago, RubberDuck said:

    Okay, I must look what I must do there :)

     

    Another Question. You have written that you have an good Morning / good Night butto.

     

    How you have done this?!


    This sounds very interesting :)

     

    @RubberDuck

     

    Sure.. here you go,...

     

    Good Morning (interacts with my alarm clock vd and other scens/vd's ) 

    • Turns off house alarm
    • plays music on master bedroom and expands to landing and kids bedrooms
    • Playing morning greeting in each bedroom through sonos (time, date, weather, temp inside) Greeting from yesterday was "Good Morning, it is 07:00  .  Today is Monday, July, 31  .  It is scattered clouds and the temperature is 18.8 degrees at 1005 millibars.  The south west wind is 18 kilometers per hour. Sunset will be at 21:24. The house temperature is 22.4 degrees."
    • Turns on lights if dark
    • switches on satellite receiver
    • changes house mode to sleep
    • sends pushover message on status

     

    Good Night (interacts with my alarm clock vd and other scenes/vd) 

    • turns off TV or satellite receiver if still on
    • Set house alarm
    • switches off rack cooling if active
    • turns off all music except in kids bedrooms
    • turns off all lights excepts some predefined ones
    • announces what time the alarm clock is set for tomorrow through landing sonos
    • resets some house mode to baseline
    • sets general house mode to awake
    • sends pushover message on status

     

     

    27 minutes ago, RubberDuck said:

    Hi, when I want to use AWS Polly. I must open an Account -> After that I must configure the settngs.json!!?

     

    yes

    28 minutes ago, RubberDuck said:

    And you wirte you have TTS Presets?! So you have an VD for that?! Can you publish it, or not?! I would try this the

     

    I use the Smart message Hub I wrote to send all my TTS  ( as it handles all my messaging ) but could put together a standalone VD example of a TTS if you like ...

     

     

     

    Link to comment
    Share on other sites

    On 8/1/2017 at 1:38 PM, AutoFrank said:

    I use the Smart message Hub I wrote to send all my TTS  ( as it handles all my messaging ) but could put together a standalone VD example of a TTS if you like ...

     

     

    Hi,

     

    can you tell me how you have done this?! I have the Sonos VD, this works. I have also the Smart Message Hub and I think this also works, because I have installed the Demo VD, and I recieve pus Messages and so on.

     

    But how I can now mke TTS, for example, that it speaks the weaher, humidity and so on, this I don't understand :(

    Link to comment
    Share on other sites

  • Topic Author
  • 13 minutes ago, RubberDuck said:

     

    Hi,

     

    can you tell me how you have done this?! I have the Sonos VD, this works. I have also the Smart Message Hub and I think this also works, because I have installed the Demo VD, and I recieve pus Messages and so on.

     

    But how I can now mke TTS, for example, that it speaks the weaher, humidity and so on, this I don't understand :(

     

    Hi @RubberDuck

     

    I use @Sankotronic Weather 1.0 VD to get get the weather data.This stores the relevant data in a number of global variables

     

    I then use the code below (VD button) to compile the morning message and then use smart message hub send to one of my sonos players

    it is a VD so I enter the IP and Port (5005) of the api in the vd details

     

    You can see the global variables the code uses at the top 

    I also use a hometable to store all my device ID's so you'll see reference like jT.cs.smsgh instead of a scene or other ID's

     

    Please login or register to see this code.

     

     

     

    Link to comment
    Share on other sites

    18 hours ago, AutoFrank said:

    I then use the code below (VD button) to compile the morning message and then use smart message hub send to one of my sonos players

    it is a VD so I enter the IP and Port (5005) of the api in the vd details

     

    Hi @AutoFrank,

     

    thanks for your reply.

     

    Okay I will check this, I have also installed the 2.0 Weather VD from @Sankotronic this works fine.

     

    One Question to the Quote, i have the VD Button on the Sonos VD?! Or where is the Button?!

     

    Can I use your Code, or I must modified it?!

     

    I must look also what is the HomeTable, I think it is a good feature, but I don't understand what that is. I think that there are stored my Device ID's so at first I must find all of them, and write there in the Table?!

    Edited by RubberDuck
    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, RubberDuck said:

    Okay I will check this, I have also installed the 2.0 Weather VD from @Sankotronic this works fine.

     

    Hi @RubberDuck

     

    weather 2.0 will work okay - you just need access to the weather data

     

     

    Link to comment
    Share on other sites

    4 minutes ago, AutoFrank said:

    weather 2.0 will work okay - you just need access to the weather data

     

    Okay, but this is the Question ;-)

     

    How I can access the Data that TTS will speak them?!

     

    Thanks for your help! It is a really great support here. I know that my question are maybe a little bit "Oh my god, why they don't know them" but this is the beginning :)

    Link to comment
    Share on other sites

  • Topic Author
  • 1 hour ago, RubberDuck said:

    One Question to the Quote, i have the VD Button on the Sonos VD?! Or where is the Button?!

     

    The button is on a separate VD but this is just the way I do it...as I have multiple greetings on the morning as well as music 

    This is the VD I use for my morning greeting ad music is like this and then a just 'press' the respective button from a scene (The code I shared is from this VD)

     

    Please login or register to see this attachment.

     

     

    1 hour ago, RubberDuck said:

    I must look also what is the HomeTable, I think it is a good feature, but I don't understand what that is. I think that there are stored my Device ID's so at first I must find all of them, and write there in the Table?!

     

    @RubberDuck

     

    There is a good post on this. You'll find it in the group of tutorials I put together  (it's also in a my signature)

     

     

     

    3 minutes ago, RubberDuck said:

    How I can access the Data that TTS will speak them?!

     

    @RubberDuck

     

    for weather 2.0 I think that relevant data is in a table stored in one global variable (in weather 1.0, it's in a number of discrete variables)

    you need to use lua to read and structure into a sentence if you want to do what I did..some user may have posted some code that retrieves it and you could use that as a start

     

    a lot of what you want to do needs some lua capability.. so if I might make a suggestion .. I think you should start to learn lua.

    It's not that difficult. There are some good online resources but I think you'll find what you need on this forum. I have thrown together a few tutorials that help, others have done the same. In addition to this, you could start to look at other peoples code and pick your way through it....

    it may seem a little daunting at first but once you've grasped some basics you'll be able to do a lot .. do a few searches on the forum and you should find enough to get started

     

     

     

    Link to comment
    Share on other sites

    Okay, this looks very interesting, would it be possibl that you share it?!

     

    Another Question, you write that you set an IP and Port by this VD, but for what?! This I don't understand?!


    Thanks for the explanation.

     

    Regards

    Link to comment
    Share on other sites

  • Topic Author
  • 11 minutes ago, RubberDuck said:

    I know that my question are maybe a little bit "Oh my god, why they don't know them" but this is the beginning

     

    @RubberDuck

    no such thing as a stupid question .. we all started our journey sometime, for me it was about 2 years ago...

    keep search posts and keep asking questions... and if you may a start on something yourself and post the code you'll get a fair bit of help from users :-)

     

    1 minute ago, RubberDuck said:

    Okay, this looks very interesting, would it be possibl that you share it?!

     

    I can but, its set up for my system and weather 1.0... here you go (attached)

     

     

     

     

    Please login or register to see this attachment.

    4 minutes ago, RubberDuck said:

    Another Question, you write that you set an IP and Port by this VD, but for what?! This I don't understand?

     

    @RubberDuck

     

    in the general tab of the VD you can add an IP and a port

    for the sonos api , the IP is the ip of the Pi or whatever you're hosting it on 

    the port is 5005 (or 5006 is you use https)

     

    Please login or register to see this attachment.

     

    If it is setup as above then the following code at the start of main loop or button will allow you to use this information 

     

    Please login or register to see this code.

     

    Link to comment
    Share on other sites

    • 2 weeks later...

    Hi,

    I have issue with State showed in Fibaro. Sonos node is showing STOPPED and Kirkoff`s one is Showing Playing. Right now music is playing so Kifkoff is correct. But when I select MUTE on sonos-node it is working. Also I`m not able to stop via node. Kikoff is working. What can be wrong? 

     

    Next question.

    Is it possible to use HA bridge to execute Play, Stop, Set volume to X via Alexa?

    Alexa, turn on Sonos -> Play

    Alexa, turn Off Sonos -> Stop

    Alexa, set Sonos to X -> volume

    Alexa, turn on next song -> Next song

    If so, how? :) (

     

     

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

  • Topic Author
  • 18 hours ago, Bezan said:

    Hi,

    I have issue with State showed in Fibaro. Sonos node is showing STOPPED and Kirkoff`s one is Showing Playing. Right now music is playing so Kifkoff is correct. But when I select MUTE on sonos-node it is working. Also I`m not able to stop via node. Kikoff is working. What can be wrong? 

     

    @Bezan

    I'll be never seen the stare incorrect as long as the main loop in running on the vd 

    If the main loop errors out it will show the last state it was 

    Check that the main loop is still running when you see this 

     

    There is no stop but there is a pause 

    There is a mute and an unmute on node-http-api

    18 hours ago, Bezan said:

    Next question.

    Is it possible to use HA bridge to execute Play, Stop, Set volume to X via Alexa?

    Alexa, turn on Sonos -> Play

    Alexa, turn Off Sonos -> Stop

    Alexa, set Sonos to X -> volume

    Alexa, turn on next song -> Next song

    If so, how? :) (

     

    Yes but the voice commands are not as you indicated. All you need to do is setup up a scene /vd with the command you need and reference that with a HA bridge entry 

     

    I have this running 

    ..but....

     

    I understand that a native alexa skill for sonos is coming and I'm waiting for that and will switch to that completely for voice command of my Sonos 

     

     

     

     

    Link to comment
    Share on other sites

    Hi,

    First time main loop was OK and it refreshed.

    NOw I have it again and there is error:

     

    "[ERROR] 21:39:10: line 9: Expected value but found T_END at character 1"

     

     

    Code not changed:

     

    "

    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("/"..zonename.."/state")
    --fibaro:debug(response)
    jsonTable = json.decode(response);
    local zonestate = jsonTable.playbackState;
    local zonetitle = jsonTable.currentTrack.title;
    local zonevolume = jsonTable.volume;
    fibaro:call(device,"setProperty","ui.lblState.value",zonestate);
    fibaro:call(device,"setProperty","ui.lblTitle.value",zonetitle);
    fibaro:call(device,"setProperty","ui.lblVol.value",zonevolume);
    --fibaro:debug(zonestate)

    "

     

    Any ideas? :)

     

     

     

     

    Link to comment
    Share on other sites

  • Topic Author
  • Hi @Bezan

     

    I have seen this if the bridge or the player becomes unavailable and the vd is trying to read status. I need to add a bit robustness to the code but I suspect that if you save the vd the error will disappear.

     

    Could you try this ? 

     

    Thanks 

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