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


Question

Posted

Hi all,

I setup  a raspberry pi with homebridge and also the sonos-http-api server.

 

Everything is working really great, however, I am a little stuck here:

 

I would like to call (open) a Url on a VD buttonpress to start the sonos function (especially the TTS).

Format of the URL is quite simple: "

Please login or register to see this link.

to say"

 

How can I do this?

 

cheers

joystick

 

 

Recommended Posts

  • 0
Posted

Something like this might push you in the right direction (not tested)

 

Put it in the VD's button and set it to LUA code.

Please login or register to see this code.

  • 0
  • Inquirer
  • Posted

    First of all thanks, but it is not working that way.

    I do not get an error though...

    • 0
    Posted

    I'll be getting my Sono tomorrow, and I will be doing some testing this week.

    • 0
    Posted

    I want to get this to work also

    • 0
  • Inquirer
  • Posted

    I'll be getting my Sono tomorrow, and I will be doing some testing this week.

     

    Hi, I was just wondering if you found a solution for this issue.

    To me this actually seems to be a simple task, where I thought this should be doable quite easy....unfortunately I do not have any experience with Lua.

     

    cheers

     

    joystick

    • 0
    Posted

    I'm short on time at the moment to install homebridge and the sonos-http-api server on myRaspberry pi.

    Do you maybe have a link to a how to, so I do not have to spend too much time on installing it!

    • 0
  • Inquirer
  • Posted

    Hi, sure:

    Homebridge:

    Please login or register to see this link.

    and for RPI installation (node installation etc):

    Please login or register to see this link.

     

    Fibaro Plugin:

    Please login or register to see this link.

     

    Sonos Http Api:

    Please login or register to see this link.

     

    cheers

     

    joystick

    • 0
    Posted

    Thank you for the link's.

     

    I might have time to look at it sometime next week (really busy at the moment).

    Did you try this?

    Please login or register to see this link.

    • 0
    Posted

    Try this:

    Please login or register to see this code.

    • 0
    Posted

    Had a quick go at it, but when doing a TTS call (ie: /sayall/Hello, dinner is ready) it will crash the node.

    Downloading new tts message file: /home/pi/node-sonos-http-api-master/static/tts/777c1576ee74806856e1da6784920afa2a661ee1-en.mp3
    could not download file 777c1576ee74806856e1da6784920afa2b661ee1-en.mp3 { [Error: getaddrinfo ENOTFOUND

    Please login or register to see this link.

    Please login or register to see this link.

    ]
      code: 'ENOTFOUND',
      errno: 'ENOTFOUND',
      syscall: 'getaddrinfo',
      hostname: 'www.nerd.host',
      host: 'www.nerd.host',
      port: 80 }

     

    I'm sure that I've missed something in the setup, but what...

    I'll have a look at it later when I've got some more time.

    • 0
  • Inquirer
  • Posted

     

    Try this:

    Please login or register to see this code.

    I tried, however, nothing... not even an error, i also tried this:

     

    Please login or register to see this code.

    but I dont even get the first log lines.... it seems that it crashes directly at the first lines...

    • 0
    Posted

    This works for me on pauseall and some of the other Sonos Http Api functions (did not test all)

     

    For me it does NOT work with the say function as it's using a "depreciated" way of converting text to speech!

    (well it looks like this in my Sonos Http Api code)

     

    The code below will do the same as typing the following in your browser:

    Please login or register to see this link.

     

    Note that the 10.0.0.105 is the IP of my Raspberry Pi. You will need to change this.

    Also note that you will not get any response back from the code!

    Please login or register to see this code.

    Does the function say work for you?

    If so, can you have a look at the file say.js (it's in /node-sonos-http-api-master/lib/actions), and post the line 211 and 212 here?

    • 0
  • Inquirer
  • Posted

    I copied some piece of Code (mainly to get German Language Support) off the issue section :

    instead of the "nerd.host" line I added:

    var url_lang;

    switch (language) {

    case "de":

    url_lang = "de-de";

    break;

    default:

    url_lang = "en-us";

    }

    var tts_request = '

    Please login or register to see this link.

    + url_lang + '&src=' + phrase;

    • 0
  • Inquirer
  • Posted

    It is working right know together with fibaro,

    BUT only with a one Word TTS message. As soon as i put in a whole sentence with space nothing is working.

    • 0
    Posted

    Try adding the following between the words

    Please login or register to see this code.

    ie: this is a test

     

    Also.. When posting code here try to use the [c o d e] [/ c o d e] tags (remove spaces between code and /code) it will make reading code much easer for all!

    • 0
    Posted

    Or try to urlencode the string:

     

    function urlencode(s)
      if (s) then
        s = string.gsub (s, "\n", "\r\n")
        s = string.gsub (s, "([^%w ])",
        function © return string.format ("%%%02X", string.byte©) end)
        s = string.gsub (s, " ", "+")
      end
      return s
    end
     

    txt2say = urlencode("Hello Joystick")

    • 0
    Posted

    Okay.. this works... Use %20 as a space!

    ie: Hello%20this%20is%20a%20test.

     

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted

    Cool, i also tried \32 which didn't work...

    Great, now let's go on and figure of how to use variables like weather, time etc.

    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
    Posted

    Weather is not really hard to do.

     

    Something like this should work for temperature.

    Please login or register to see this code.

    • 0
    Posted

    a very quick put together example weather code.

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