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

  • 1

The action "page" is where you write your Lua code.

On Declaration "page" on left you define your triggers and conditions.

Could you post your HC2 Lua scene and we can work on that to see how to transfer.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Hi cag014,

     

    at HC2 I had used the following LUA Code:

     

    --[[
    %% properties
    %% weather
    %% events
    9 CentralSceneEvent 3 Pressed
    %% globals
    --]]

    local startSource = fibaro:getSourceTrigger();
    if (
     ( (startSource["type"] == "event" and startSource["event"]["type"] == "CentralSceneEvent") )
    or
    startSource["type"] == "other"
    )
    then
          local http = net.HTTPClient()  
      http:request('https://maker.ifttt.com/trigger/startFavoritPlaylist/with/key/xxx', {
          success = function(resp)
            if resp.status == 200 then
              fibaro:debug(resp.status)
            else
              fibaro:debug(resp.status)
           
            end
          end
        })
    end

     

    In the meantime, I was informed by the German Fibaro Support that it would no longer work as in the HC2. I would have to set up using the Quick App. The only problem is that I have no idea about it. Why, however, as before, no HTTP page can be integrated directly into the LUA script is not understandable to me ...

     

    HItman_85

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • What does Fibaro do ... Why do you only change this in the scene ... Can you tell me how I should put it all in the quick app?

    Edited by Hitman_85
    Link to comment
    Share on other sites

    • 0

    Could you post which device (keyfob?) you're using to trigger the scene?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • That is the corresponding trigger for Fibaro Keyfob:
     
    {
      conditions = { {
          id = 48,
          isTrigger = true,
          operator = "==",
          property = "centralSceneEvent",
          type = "device",
          value = {
            keyAttribute = "Pressed",
            keyId = 4
          }
        } },
      operator = "all"
    }
     
    If I understand it correctly, do you first have to create a virtual device under Quick App and can you then control it on the "Action" page?
    Edited by Hitman_85
    Link to comment
    Share on other sites

    • 0

    Yes... conditions are OK. (keyid=4? in Lua scene I think it is 3)

    Yes.. but not control it, to run it.

    Link to comment
    Share on other sites

    • 0

    Here is a QuickApp template for you. For use in scene use follow

    Please login or register to see this code.

    Currently no response received

    Addition features:

    1. by pressing "Test HTTP" button you should receive HC3 service status

    2. by clicking on QD icon (like turn ON/OFF) you should receive HC3 LEDs status.

    3 Any above actions will set icon to "ON" state during HTTP execution and back to "OFF" after...

     

    Since icons are not transferred here custom icons for QuickApp

    Please login or register to see this image.

    /monthly_2020_02/router_off.png.c5044e67677382edee0ba0218d3b6691.png" />router_on.png.c94af9d4ea33d863fe9a7e4a7322a8fd.png

    Currently QuickApp label is not resizable.  Should be fixed in next release

     

    Please login or register to see this attachment.

    Edited by cag014
    Link to comment
    Share on other sites

    • 0

    Yes... in your case you can use it as is.

    According to your Lua scene, you didn't check the response. So replace  all line below

    8 hours ago, Hitman_85 said:

     local http = net.HTTPClient()  
      http:request('https://maker.ifttt.com/trigger/startFavoritPlaylist/with/key/xxx', {
          success = function(resp)
            if resp.status == 200 then
              fibaro:debug(resp.status)
            else
              fibaro:debug(resp.status)
           
            end
          end
        })

    to

    fibaro.call(<QD-ID>, "getHttp",'https://maker.ifttt.com/trigger/startFavoritPlaylist/with/key/xxx')

     

    It should work same as before.

    let me know if it works. (interesting if HTTPS will work)

     

    Edited by cag014
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Now I have compromised the problem that the scenes can be. Only with my keyfob there are still problems I can start the music but not turn it off.

     

    Edit:

    Apparently there is a bug with the keyfob. No matter which key I assign, the music is always started. Now I have tested the Aeotec Wallmote. Here it works and the music stops when you press the corresponding button.

     

    What do I have to do to make it even quieter or louder? In the block scene I can only choose turn on and off. Where do I have to adapt the template exactly to be able to choose these commands?

    Edited by Hitman_85
    Link to comment
    Share on other sites

    • 0

    There is no way to do it with block scenes.

    I'm confused,  did it work in Lua scene that you've posted?

    I do believe that yo need to send different HTTP command for every key to turn it ON/OFF/VolumeUP or down.

    In addition I see you're using IFFT , so may be you can define there different actions.

    Unfortunately I don't have Sonos and not familiar with his remote control.

    Edited by cag014
    Link to comment
    Share on other sites

    • 0

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

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • It also works for me as a block scene. I simply adjusted the LUA script in the Quick App. It's just not clear to me how I can manage to have even more options in the block scene.

    Screen:

    Please login or register to see this link.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 3 minutes 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.

    Yes, that was the first thing I tested. In the block scene you cannot choose anything here. You can only use the plugin in the dashboard.

    Link to comment
    Share on other sites

    • 0

    Hi Guys,

     

    Got my HC3 today and first imprestions, well not great.

     

    Where do you find plugins compatible for HC3 ?. Cant find the place were you can look for plugins.

     

    Dont like the new UI very much, the old one was more helpful instead of jumping through a tone of tabs in case you missed something.

     

    I am going to stick with the old HC2 for the timebeing until this matures a bit more I thing

     

    Link to comment
    Share on other sites

    • 0
    3 minutes ago, Graham said:

    Where do you find plugins compatible for HC3 ?. Cant find the place were you can look for plugins.

    go tot devices-> add->other devices

    Scroll all over the page or choose type.

    12 minutes ago, Hitman_85 said:

    You can only use the plugin in the dashboard.

    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

    Link to comment
    Share on other sites

    • 0

    Thanks guys,

     

    Well I found the plugins after looking at your surgestion. Thank you

     

    Have setup five rooms with Sonos, but well not much in this plugin from Fibaro.

     

    I am going to have to wait so I can setup my TTS and MP3 playback from scenes once can get my head round all the changes. I wish there was a dark mode for this dashboard, too bright working on this in the everning.

    Link to comment
    Share on other sites

    • 0
    7 minutes ago, Graham said:

    I am going to have to wait so I can setup my TTS and MP3 playback

    I see that a lot of users using this complex solution for TTS. I don't know if it worth the efforts to record messages.

    May I suggest to use more simplistic solution if you have android tablet (or in my case I'm using old android phone w/o SIM and external speakers).

    Take a look on

    works excellent for me.

    One of the advantages that I send TTS message to my private phone as well, so I never miss a message even during the night.(keeping my phone beside the bed)

    Edited by cag014
    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...