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


  • 0

Working SONOS VD and TTS workaround - quick install guide


Question

Posted (edited)

hello all.

i have just bought some Sonos speakers and wanted to integrate with home center 2. 

first part is to control then second part text-to-speech workaround

 

whilst i was going through the forums i found the info i needed scattered around different threads and the original thread was very long, so i have thought i might make it easier by creating a small quick guide:

 

First thing is all credit to the virtual device goes to krikroff for the VD, original thread here -  

Please login or register to see this link.

 

I have created a video demo instead as it was easier to show rather than write.

 

 

 

video link is as above.

 

enjoy...

 

download link here:    

Please login or register to see this link.

Edited by morpheus75
update video link
  • Like 2

Recommended Posts

  • 0
Posted

If im not mistaken the krikoff addon actually only supports 1x sonos.

You would need to change code and make extra global vars with different names for each sonos.

 

Or just grp up all sonos and play the alarm via 1x sonos and if they are grouped both will play.

  • 0
Posted

I have noticed the 30 second limit too, couldn't find anything that restricts it though.

  • 0
  • Inquirer
  • Posted

    there is a 30 sec time limit but i couldnt work out where to change it

    • 0
  • Inquirer
  • Posted

    on the other thread a member 'rankman' has figured a work around out and am posting it here

     

     

    rankman, on 29 Dec 2015 - 2:10 PM, said:

    Please login or register to see this link.

    Hello,

     

    In the play function change the value off 10 in a higher value.

    Now each value is arond 2 second so a value of 10 is around 20 seconds.

    If you need three minutes you have to change this value to 180/2= 90 or a little less.

     

    Also you can comment out the stop function.

     

     

    while (currentTransportState == "PLAYING") do
              if (i > 10) then break end;
              getTransportState();
              fibaro:debug(currentTransportState);
              fibaro:sleep(2000);
              i = i + 1;
            end

     

    i have tested both ways and they work very well.

     

    we can use this to play notifications greater than the 30 secs.

     

    we can also use this work around by possibly creating a .m3u playlist file and storing that in our network drive.

    i have created 1 and used the global variable to change the frontsonos to test.m3u and it did it.  i then pressed the play button and it played the tracks through the playlist and it showed what was actually being played in the sonos app.

    if you set a time in the code above it will play for that length of time only but if you comment out the 'stop function' then it would continue until you press 'stop' or it goes to the end of the playlist.

    the disadvantage is that the queue in the sonos app will remain as 'not in use' and whatever order you created the playlist in is what order it will be played.

    at this moment this is the only way i see we can get fibaro to add the playlists to sonos.

    code is

     

    fibaro:setGlobal("frontsonos", "//Diskstation/Music/audio/test.m3u")
    fibaro:call(190, "pressButton", "1")
     
    if we create a simple VD with multiple buttons and assign the buttons these 2 lines of code, changing just the underlined text to you playlist name and path and of course the ID of the virtual device in line 2 then possibly create a mini remote of playlists as single button presses.
     
    these would continue playing until they finish all the songs in the list unless we add another button with a 'stop' or 'pause' command.  but remember if you press 'stop' and subsequently press 'play' again it will start from the beginning.
     
    hope this helps..... and thanks to 'rankman' for the highlighted code
    • 0
    Posted

    Hi Morpheus75,

     

    Great Work, well done!

     

    Could you pease let us know where to find professional mp3 files such as the one played in your movie.

     

    Thanks in advance.

    • 0
  • Inquirer
  • Posted

    Hi Morpheus75,

     

    Great Work, well done!

     

    Could you pease let us know where to find professional mp3 files such as the one played in your movie.

     

    Thanks in advance.

    cheers

     

    mp3 files i googled a text-to-mp3 site and used a website to create mine, later on i got my daughter to read out the statements and recorded her voice, so now all my announcements are in my daughters voice

    • 0
    Posted

    For English I use this:

    Please login or register to see this link.

    • 0
    Posted
    On 10/13/2015 at 5:37 AM, morpheus75 said:

    hello all.

    i have just bought some Sonos speakers and wanted to integrate with home center 2. 

    first part is to control then second part text-to-speech workaround

     

    whilst i was going through the forums i found the info i needed scattered around different threads and the original thread was very long, so i have thought i might make it easier by creating a small quick guide:

     

    First thing is all credit to the virtual device goes to krikroff for the VD, original thread here -  

    Please login or register to see this link.

     

    I have created a video demo instead as it was easier to show rather than write.

     

    Please login or register to see this link.

     

    video link is as above.

     

    enjoy...

     

    download link here:    

    Please login or register to see this link.

    Hi Morpheus, The link there no longer works. Any chance you have an updated version?

     

    • 0
  • Inquirer
  • Posted

    @Smarterelec

     

    hi

    thanks for reminding me to update this thread. i forgot about it!!!

     

    i have updated above thread and download files. but you can just visit my channel direct on

    youtube.com/yorkshireautomation

     

    cheers

     

    • Thanks 2
    • 0
    Posted

    @Morpheus75

     

    I Have the scene that you use in the youtube video for TTS ticked over, but i get an error message:

    [DEBUG]  [fatal] Unknown exception: /opt/fibaro/scenes/133.lua:36: 'end' expected (to close 'function' at line 30) near.

     

    Lua code/scene:

    --[[
    %% properties
    %% events
    %% globals
    ttsone
    --]]

    -- sid is the Virtual Device ID
    -- 28 is the Process button ID

    local sid, bid = 401, 28
    local ttsmessage = fibaro:getGlobal("ttsone")
    local vol = fibaro:getGlobalValue("vdVol")
    -- Create TTS paroms object
    local params = {
      
    --TTS Message
     
    message = ttsmessage,
      
    duration = 'auto',  -- Duration: "auto", xx seconds
    language = "en-gb", -- Language: see

    Please login or register to see this link.


      
    volume = vol        -- Volume

    local _f = fibaro

    local _x ={root="x_sonos_object",load=function(b)local c=_f:getGlobalValue(b.root)
       
    -- Make a request to the remote to process params object instantly
        
    _x:set(tostring(sid), { tts = params })
     
    _f:call(sid, "pressButton", bid)

     

     

     

    • 0
  • Inquirer
  • Posted

    I'm away at moment will have a look at it when I get back on Tuesday.

    Cheers

    • 0
    Posted

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted

    @chatboy

    did you copy the scene completely?

     

    Please login or register to see this code.

    • 0
    Posted

    guys.

     

    maybe it's off topic..

    but using node-red it's very easy

    just call url  http://192.168.1.45:1880/tts/text?Attention!

     

    for calling from HC2 it's 3 lines in VD or scene on LUA

     

    here is flow

    Please login or register to see this code.

    and icing on the cake: weather forecast via wunderground

     

    Please login or register to see this code.

     

    Please login or register to see this image.

     

    PS: please change ":ru" lang on "en" in flow

    • Like 1

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