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

Please help with this QA


matnowys

Question

Can anyone help with QA?

Needed QA to :

- after pressing the button it did "open" a given device

- check the status of the binary sensor and returned its value in the form "open" when true or "closed" when false

- enter the sensor status in the QA label

 

example:

function QuickApp:wjazd_open() -- QA button
hub.call(1955"open") -- gate open (smart implant on/off switch)
self:updateView("wjazd_label""text""Brama wjazdowa: " .. tostring(hub.getValue(152"value")) ) -- 152 gate opening sensor 
end
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
On 12/21/2023 at 11:42 AM, matnowys said:

Can anyone help with QA?

Needed QA to :

- after pressing the button it did "open" a given device

- check the status of the binary sensor and returned its value in the form "open" when true or "closed" when false

- enter the sensor status in the QA label

 

example:

function QuickApp:wjazd_open() -- QA button
hub.call(1955"open") -- gate open (smart implant on/off switch)
self:updateView("wjazd_label""text""Brama wjazdowa: " .. tostring(hub.getValue(152"value")) ) -- 152 gate opening sensor 
end

If your goal is to update a Quickapp label when the gate sensor is true, your approach is incorrect..

You can't do it from inside the quickapp function that actually opens the gate. There must be an event listener or a loop that listens to the gate sensor status.

It's not correct to check the gate status right after the button press, in a function where you just opening the gate, becuase it will not work.

If you press the button then the function is called that opens your gate, and if you check your gate sensor status right at that moment, your sensor will report probably a false value.

Its because you are checking the sensor status just miliseconds after the gate is actually opening, but in reality it does not happen that fast, so you will get a fake result.

There are a couple of ways to achieve your goal, but the most simpliest way is to use a single loop for checking gate status. / later if you get more familiar with quickapps you can use subscriber functionality or some event listening pracitces /

 

Please login or register to see this code.

 

 

Edited by Neo Andersson
Link to comment
Share on other sites

  • 0
  • Inquirer
  • Works great!

     

    @Neo AnderssonOne more thing - how can I use two listenToSensor functions in one QA? I need to check status of two sensor and show their value on different labels.

    Edited by matnowys
    Link to comment
    Share on other sites

    • 0
    2 hours ago, matnowys said:

    Works great!

     

    @Neo AnderssonOne more thing - how can I use two listenToSensor functions in one QA? I need to check status of two sensor and show their value on different labels. You dont need to use 2 functions. You can listen to both sensors in the same function.

    Please login or register to see this code.

     

    Edited by Neo Andersson
    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...