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

Detect KeyID and/or keyAttribute in a QA Loop from a device


Apax

Question

Hi All!

 

I have created a loop in a QA and need to detect if a button (from a 8-button device, Scene Master - ZRC-90 - Remotec) has been singleclick or dubbleclick and which one 

Normaly I simple use this:

 

{
  conditions = { {
      id = 162,
      isTrigger = true,
      operator = "anyValue",
      property = "centralSceneEvent",
      type = "device"
    } },
  operator = "any"
}

 

 

local trigger = sourceTrigger

if (trigger.value.keyId==1 and trigger.value.keyAttribute=="Pressed" )

 

 

 

But in this case we do not have this device as a "sourceTrigger"

I have tried diffrent ways but can not get it to work

 

function QuickApp:loop(KeyCodeQA)

    local trigger = hub.getValue(162, "value")

    if (trigger.keyId==1 and trigger.keyAttribute=="Pressed" )

end

 

 

 

Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0


Triggers are for scenes, if I understand you well, you have to use api.get("/events/history") in your QA to check with button was pressed

Link to comment
Share on other sites

  • 0
  • Inquirer
  • all right , that´s an idea 
    so there is no way to just read check the device status like motion detector or simular 

    Link to comment
    Share on other sites

    • 0

    You could install TriggerQA

    Please login or register to see this attachment.

     

    It's a QA that runs in the background and sends "sourceTriggers" to other QAs that want them.

     

    In your QA do

     

    Please login or register to see this code.

     

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

    • 0
  • Inquirer
  • Hi jgab!

    This was a nice one :) 
    thank you very much, i have never imported a script that works direct.

    Great job! 

     

    For those who read this and want to use this script, change line 7 to only one ":"

    Link to comment
    Share on other sites

    • 0
    1 hour ago, Apax said:

    For those who read this and want to use this script, change line 7 to only one ":"

    Thanks, fixed in post.

    The script allows to subscribe to multiple events. The events that are supported are

    Please login or register to see this code.

    Also, it's advantageous to be as specific as possible in the subscription pattern as your QA will be sent less events (and less work to do)

    Ex. If you only want centralSceneEvent from deviceId 162 do

     

    Please login or register to see this code.

    If you only want from keyid 6 do

    Please login or register to see this code.

     

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

    • 0
  • Inquirer
  • after implement this code in to some QA´s, I would like to expand with some cron as well ( sun´state´ and exact time)  but i do not get it to work.

     Could you please give me some hints, in the right direction 

    self:subscribe({type='cron', time=<cronString>, tag=<string>})
     

     

    Link to comment
    Share on other sites

    • 0

    Please login or register to see this code.

     

    was a bug in cron handling - fixed in v1.23

    Edited by jgab
    Link to comment
    Share on other sites

    • 0
    3 hours ago, jgab said:

    Please login or register to see this code.

     

     

    Thank you for adding Trigger QA

    I know it have been available for some time, but Eventrunner for until now been sufficient for me

    But it looks great and i'm curious to use it

     

    Could you elaborate a little more how to use?

    Please login or register to see this link.

    Please login or register to see this link.

    with the code you like to run, based on the triggers

     

    In Trigger QA you have  ----------- Helper functions -------------- 

    They need to be copied to my own QA right ? but they giving an Error, that a end is missing 

    I added a END to the clearSubsciption function, han hope it placed the Correct place.

     

    Please login or register to see this spoiler.

     

    And one last observation.

    The Trigger QA provided above is v1.22 and the QA updater in v1.21 :-) 

     

     

     

     

     

     

     

     

    Edited by ChristianSogaard
    Typo
    Link to comment
    Share on other sites

    • 0

    Yes, clearSubscriptions lacks an 'end' at then end...

     

    Yes there is one TriggerQA and then you can have multiple QAs that subscribe to events.

    The trick is that the QAs subscribing needs to set a QUickAppVariable named 'TRIGGER_SUB' to a lua table with the events it wants to subscribe to. The helper functions are just helping with setting and clearing that variable.

    Sorry, bug with cron. I will update to 1.23. (I changed fibaroExtra libs)

    Pushed v1.23 to UpdaterQA

    • Thanks 1
    Link to comment
    Share on other sites

    • 0
    41 minutes ago, jgab said:

    Yes, clearSubscriptions lacks an 'end' at then end...

     

    Yes there is one TriggerQA and then you can have multiple QAs that subscribe to events.

    The trick is that the QAs subscribing needs to set a QUickAppVariable named 'TRIGGER_SUB' to a lua table with the events it wants to subscribe to. The helper functions are just helping with setting and clearing that variable.

    Sorry, bug with cron. I will update to 1.23. (I changed fibaroExtra libs)

    Pushed v1.23 to UpdaterQA

    Morning Jan and thank you

    i refreshed the QAUpdater and the TriggerQA is still on 1.21

    Link to comment
    Share on other sites

    • 0

    Too early in the morning - now I've updated the right file and 1.23 should show up.

    • Thanks 1
    Link to comment
    Share on other sites

    • 0
    7 minutes ago, jgab said:

    Too early in the morning - now I've updated the right file and 1.23 should show up.

    Works works and works -great stuff, and ? ☺️ thank you

    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.

    ×
    ×
    • Create New...