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

Set device property in QA


Bernhard Stockman

Question

In a QA I use fibaro.getValue(deviceID, property) to get the property value. I also need to set a device property value

but I can not find a corresponding fibaro.setValue function. How do I set a device property value from within a QA?

Link to comment
Share on other sites

Recommended Posts

  • 0
  • Inquirer
  • OK. In a normal programing environment you would expect an error message if you tried something that is not possible. ?

    Thanks for the help anyway.

     

    Link to comment
    Share on other sites

    • 0
    5 minutes ago, Bernhard Stockman said:

    OK. In a normal programing environment you would expect an error message if you tried something that is not possible. ?

     

    Yes, that's a very reasonable expectation . Unfortunately Fibaro made it easy for themselves but difficult for developers. (long rant

    Please login or register to see this link.

    )

    Link to comment
    Share on other sites

    • 0

    So, fibaro.call returns nada, that we know.

    A fibaro.call is translated to an api call that look like

    Please login or register to see this code.

    the updateProperty call could look like

    Please login or register to see this code.

     

    Most api calls (I haven't checked all) returns an error (HTTP 404) if the device doesn't exist. However, fibaro.call doesn't return that to us, it just silently ignores it without telling us.

    If we call an action in a QA that doesn't exist we don't get any message back either from the api.post - just a HTTP 202. We can go to the called QA and have a look and see that it will complain in the log that there is no handler for that action. But the caller gets nada.

    If we with this api try to update a non.existent (or read only) property we get also an HTTP 202 back

    ...However, 202 is kind of "non-committal"...

    Please login or register to see this code.

    It sums up pretty good Fibaro's relationship with it's users - non-committal ;-) 

     

    ...so I guess by reading the fine-print we see that they get away with this behaviour...

    ...but they could at least throw us an error if we try to access non existent devices?

     

    (The "REST" people advocate 202 if you need asynchronous requests, but recommends 200 if the result can be calculated reasonable fast. If you return 202 they also recommend that you return a ptr to a resource that can be queried for the result...

    From RFC7231

    Please login or register to see this code.

    )

     

    If there is to be a market for QAs we can't put all the burden on the users of the QA. Calling the QA wrongly is just met by silence and in best case they have to go into the log of the QA to see if there were any errors - or into the swagger interface to see if it was updated?

     

    To be clear, I do not advocate all api requests to be 200, but more of them could check the validity of the request as it is often easy to check and return something better than just 202... and even if the api is asynchronous the Lua fibaro functions could hide that as show in this

    Please login or register to see this link.

    but it is unnecessary cumbersome if we don't have better error messages from the api...

    Edited by jgab
    • Like 1
    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...