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
Search the Community
Showing results for tags 'syntax'.
-
I have used a LUA script which is triggered by pushing the switch 2 on a Fibaro switch. Depending on whether the key is pushed once, twice or held, I control another device (a light) according to set rules. How the key is pushed, is found by the variable pressSource = fibaro:getSourceTrigger().event.data. This solution has been used previously by several contributors on the forum. My current code looks like this (only first part shown): --[[ %% properties %% events 394 CentralSceneEvent %% globals --]] -- Uses first slave for "CentralSceneEvent" ID (not master, not switch itself). Here 394 local trigger = fibaro:getSourceTrigger() if (trigger.type == "other") then fibaro:debug("Scene started by clicking 'start' button") else local pressSource = fibaro:getSourceTrigger().event.data fibaro:debug("New: CentralSceneEvent received from key: " .. pressSource.keyId) if (pressSource.keyId == 2) then local ledId = "306" local ledValue = fibaro:getValue(ledId, "value") if pressSource.keyAttribute == "Pressed" then fibaro:debug("Pressed") if ledValue == "0" then fibaro:call(ledId, "turnOn") else fibaro:call(ledId, "turnOff") end elseif pressSource.keyAttribute == "Pressed2" then fibaro:debug("Pressed 2 times") fibaro:call(ledId, "setValue", "100") elseif pressSource.keyAttribute == "HeldDown" then -- etc. (complete code not shown) I now want to add a second trigger, i.e. another Fibaro switch being pushed. Depending on which switch is used, I want different lights to be adjusted. Below is my first edit (still incomplete). In line 5, the new trigger 494 is added. How do I know if the scene was triggered by 394 or 494? The answer is probably in fibaro:getSourceTrigger(), but I cannot find the complete specification for this function documented anywhere. Specifically: - How do I find whether 394 or 494 was the trigger? The syntax trigger.event.id in line 14 is my guest guess. What is correct? - Once I have the right triggerID, I can easily make the variable ledID dependent on triggerID, by having two related lists (arrays): {394, 494} for the triggers and {306, 406} for the corresponding LED lights. This needs to be implemented in line 18. Can anyone please provide a more complete specification for the data returned by fibaro:getSourceTrigger in HC2, and show me how I can use it to implement double triggers? Or are you all too busy converting to HC3? PS: I have simplified this to TWO triggers. In reality I want to have several more. But if I can do two, I can do any number. --[[ %% properties %% events 394 CentralSceneEvent 494 CentralSceneEvent -- <<--- NEW TRIGGER %% globals --]] -- Uses first slave for "CentralSceneEvent" ID (not master, not switch itself). Here 394 and 494 respectively. local trigger = fibaro:getSourceTrigger() if (trigger.type == "other") then fibaro:debug("Scene started by clicking 'start' button") else local triggerID = trigger.event.id -- <<--- WHAT IS CORRECT SYNTAX?? local pressSource = fibaro:getSourceTrigger().event.data fibaro:debug("New: CentralSceneEvent received from key: " .. pressSource.keyId) if (pressSource.keyId == 2) then local ledId = "306" -- <<<< NEEDS TO BE CHANGED TO CORRESPOND TO triggerID local ledValue = fibaro:getValue(ledId, "value") if pressSource.keyAttribute == "Pressed" then fibaro:debug("Pressed") if ledValue == "0" then fibaro:call(ledId, "turnOn") else fibaro:call(ledId, "turnOff") end elseif pressSource.keyAttribute == "Pressed2" then fibaro:debug("Pressed 2 times") fibaro:call(ledId, "setValue", "100") elseif pressSource.keyAttribute == "HeldDown" then fibaro:debug("HeldDown") -- etc. (complete code not shown)
-
Hi to all, Sorry if I started a new discussion but I don't find information about my doubt. My main need is to send some information from an external server to HC2 ... to a scena ... or a virtual device... I try to call HC2 through API from another server using REST API but i cannot find the correct syntax to ... for examples "press a button " in a virtual devices... There is someone that can help me? Thanks a lot in advance Paolino
-
What is the syntax of sonos "text-to-speech" function in lua?