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

LUA script for Sonos


Hitman_85
 Share

Question

Hello everybody,

 

I climbed from HC 2 to HC 3. Actually I thought it would be possible to trace all the scenes. Unfortunately, Fibaro has adapted the LUA Editor. Since then I have tried unsuccessfully to put the IFTTT webhook trigger that I had set up for Sonso back on the Fibaro keyfob. Can anyone help me what exactly I have to enter for a LUA code on the "Action" page ????

 

Hitman_85

 

 

Edited by Hitman_85
fehler
Link to comment
Share on other sites

Recommended Posts

  • 0
10 hours ago, cag014 said:

@Tony270570, @robw

Guys I think you have Sonos and probably familiar how to control it... any help is welcome.

Thanks in advance

@Hitman_85

By the way there is plugin for Sonos in HC3, did you try it?

Please login or register to see this spoiler.

 

 

I will try to look into this, but I can´t promise when. I am not a coder so it is slow work for me. I have added the Sonos plugin and it works. But I haven't done any code to control it by myself yet. I will try to make a "Wake up clock" someday :)

Link to comment
Share on other sites

  • 0
  • Inquirer
  •  

    13 hours ago, cag014 said:

    go tot devices-> add->other devices

    Scroll all over the page or choose type.

    Well, this is not entirely true. You can activate all plugins' buttons (including volume) using Lua scene and QuickApp getMyHttp.

    Do you want to try it? I'll provide buttons' url

     

    The problem is that I just have no idea about LUA. It is not clear to me how I build your template, the plugin, into an LUA scene. Could you create a template that I can easily include as a beginner?

    Link to comment
    Share on other sites

    • 0

    OK.. I'll post a scene that works with QQ template.

    Meanwhile could you please upload the getMyHttp.fqa  into system and post the ID number

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • The ID of getMyHttp is 54 and of Sonos Plugin 50. My Keyfob have the ID 48. Thank you in advance for your support.

    Link to comment
    Share on other sites

    • 0
    On 2/17/2020 at 8:54 PM, cag014 said:

    @Tony270570, @robw

    Guys I think you have Sonos and probably familiar how to control it... any help is welcome.

    @cag014 Sorry I didn't answer to you !! What are your trying to achieve exactly. how can i help ? to be trensparent i was using sonos mainly for TTS, but i switched to Alexa. Cheaper...

     

    Link to comment
    Share on other sites

    • 0
    18 minutes ago, Tony270570 said:

    @cag014 Sorry I didn't answer to you !! What are your trying to achieve exactly. how can i help ? to be trensparent i was using sonos mainly for TTS, but i switched to Alexa. Cheaper...

     

    Thanks for your reply.

    It's OK, we're trying to use Sonos plugin now.

    I'm curious how you've switched to Alexa ?

    Edited by cag014
    Link to comment
    Share on other sites

    • 0

    @cag014 with Sonos i was using @Krikroff VD, tell me if you need extra info.

    Regarding alexa I'm using this:

    it work nicely and absolutly fast. It just has a limitation, you should predefine the text and can't compose it dinamically, but except that it's really cool and cost less then a sonos for tts few euros per year. 

    And the support is great ;)

    Link to comment
    Share on other sites

    • 0
    1 hour ago, Tony270570 said:

    It just has a limitation, you should predefine the text and can't compose it dinamically,

    Thanks for sharing...

    For me predefined text, it is pretty "big" limitation. I'll stick with Android... any text anywhere.

     

    Link to comment
    Share on other sites

    • 0
    9 minutes ago, Tony270570 said:

    I fully understand @cag014, I hope that one day or another the skill will be able to handle this functionnality.

    Let's hope fibaro will add that to HC3. I have exchanged few emails with them on that and at the end they said they'll consider this option.

     

    Link to comment
    Share on other sites

    • 0

    Agree. By the way since HC3 doesn't have speaker output, I've suggested to route TTS to mobile/tablet application.

    Link to comment
    Share on other sites

    • 0
    6 hours ago, Hitman_85 said:

    The ID of getMyHttp is 54 and of Sonos Plugin 50. My Keyfob have the ID 48. Thank you in advance for your support.

    @Hitman_85

    Since we're using plugin, getMyHttp is not required (I hope)

    Let's try one action, please follow next steps:

    1.  Make sure correct IP defined in plugin of your Sonos speaker.
    2.  Start to play some music on Sonos and pause it. I mean on Sonos speaker itself.
    3. Create lua scene.
    4. Insert line below in "Actions" section of Lua scene

    Please login or register to see this code.

          5. Insert lines below in "Declarations" section of Lua scene

    Please login or register to see this code.

     6. Press "Save"  

    7. Now press key 4 on key fob. Sonos should start to play.

    Let me know if it works?

     

    Edited by cag014
    Link to comment
    Share on other sites

    • 0
    12 hours ago, cag014 said:

    @Hitman_85

    Since we're using plugin, getMyHttp is not required (I hope)

    Let's try one action, please follow next steps:

    1.  Make sure correct IP defined in plugin of your Sonos speaker.
    2.  Start to play some music on Sonos and pause it. I mean on Sonos speaker itself.
    3. Create lua scene.
    4. Insert line below in "Actions" section of Lua scene

    Please login or register to see this code.

          5. Insert lines below in "Declarations" section of Lua scene

    Please login or register to see this code.

     6. Press "Save"  

    7. Now press key 4 on key fob. Sonos should start to play.

    Let me know if it works?

     

     

    The Fibaro Sonos plugin provided on the HC3 supports

    fibaro.call(<sonosID>,"play")

    fibaro.call(<sonosID>,"stop")

    fibaro.call(<sonosID>,"pause")

    fibaro.call(<sonosID>,"setVolume",<volume>)

    ...what I could find...

     

    On the other hand, if retrieving the definition (api.get("/devices/<id>")) it shows that it should support action turnOn, turnOff, and setVolume - and the 2 first doesn't work.

    Edited by jgab
    Link to comment
    Share on other sites

    • 0
    1 hour ago, jgab said:

    The Fibaro Sonos plugin provided on the HC3 supports

    fibaro.call(<sonosID>,"play")

    fibaro.call(<sonosID>,"stop")

    fibaro.call(<sonosID>,"pause")

    fibaro.call(<sonosID>,"setVolume",<volume>)

    Since I don't have Sonos speaker, my observation based on data from API and no actions were listed there.

    By refreshing the page actions appeared... bug in hc3?

     

    So @Hitman_85 use as suggested by @jgab

    Replace line

    Please login or register to see this code.

    by

    Please login or register to see this code.

     

    Edited by cag014
    Link to comment
    Share on other sites

    • 0

    Thank's to @jgab and @cag014, here is a very simple Sonos Wakeup scene. It triggers by an exact time, on the days chosen. In this example it runs on Mondays, Tuesdays, Wednesday, Thursdays and Fridays, and the Sonos starts playing at 05:55 AM. It plays for 15 minutes (set in Actions fibaro.setTimeout) and then stops. Change your Sonos ID to your own number. In the example it is 99 in fibaro.call in Actions.

     

    Put the code below in Declarations:

     

    {
    conditions = { {
    isTrigger = false,
    operator = "match",
    property = "cron",
    type = "date",
    value = { "*", "*", "*", "*", "1,2,3,4,5", "*" }
    }, {
    isTrigger = true,
    operator = "match",
    property = "cron",
    type = "date",
    value = { "55", "05", "*", "*", "*", "*" }
    } },
    operator = "all"
    }
     
    Put the code below in Actions:
     
    fibaro.call(99, 'play')
    fibaro.setTimeout(900000, function()
    fibaro.call(99, 'stop')
    end)
    Link to comment
    Share on other sites

    • 0
    1 hour ago, robw said:

    Thank's to @jgab and @cag014, here is a very simple Sonos Wakeup scene. It triggers by an exact time, on the days chosen. In this example it runs on Mondays, Tuesdays, Wednesday, Thursdays and Fridays, and the Sonos starts playing at 05:55 AM. It plays for 15 minutes (set in Actions fibaro.setTimeout) and then stops. Change your Sonos ID to your own number. In the example it is 99 in fibaro.call in Actions.

     

    Put the code below in Declarations:

     

    {
    conditions = { {
    isTrigger = false,
    operator = "match",
    property = "cron",
    type = "date",
    value = { "*", "*", "*", "*", "1,2,3,4,5", "*" }
    }, {
    isTrigger = true,
    operator = "match",
    property = "cron",
    type = "date",
    value = { "55", "05", "*", "*", "*", "*" }
    } },
    operator = "all"
    }
     
    Put the code below in Actions:
     
    fibaro.call(99, 'play')
    fibaro.setTimeout(900000, function()
    fibaro.call(99, 'stop')
    end)

     

    It's possible to combine the conditions. I don't understand why they don't do it in the examples in the manual.

    Please login or register to see this code.

     

    Edited by jgab
    • Like 1
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I'm still having problems ... The scene works with fibaro.call (50, "play"), but it doesn't work with the keyfob. When I start the scene once, the buttons react. Strangely, when you turn it off, the first song in the playlist is played again. Does anyone know why?

     

    Declarations

    {
    conditions = { {
    id = 48,
    isTrigger = true,
    operator = "==",
    property = "centralSceneEvent",
    type = "device",
    value = {
    keyAttribute = "Pressed",
    keyId = 4
    }
    } },
    operator = "all"
    }

     

    Aktion

    fibaro.call(50, "play")

     

    Link to comment
    Share on other sites

    • 0

    Is your scene in Auto mode?

    Please login or register to see this spoiler.

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • No, the scene is on manual. Would this be wrong?

     

    Edit:

    I also just tried it on automatic. With the X on the keyfob, the music starts again at the beginning of the playlist, although it should actually stop.

    Edited by Hitman_85
    Ergänzung.
    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.

     Share

    ×
    ×
    • Create New...