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

can I get back some QAs property value using self?


Question

Posted

Hi

Can i get back some property values of a quickapp device, using the instance object "self"?

 

Like

 

getting back a thermostat QA device setpoint i am using

 

Please login or register to see this code.

isnt there a shorter way, somehow using the self object?

 

same goes for other properties like value in case of switches, sensors etc

 

I am asking, becasue i read somewhere, that performance wise using the self object is quicker and having less impact on the system

5 answers to this question

Recommended Posts

  • 0
Posted

setpoint = self.properties.heatingThermostatSetpoint

  • 0
Posted

Be careful with that. I usually treat the self.property as a cache...
The reason is that it is set when the QA starts up and is given the current device structure .properties value.
After that, the self.properties is only updated when we do a self:updateProperty(prop, value) (or an action that results in a self:updateProperty)
Are there other ways that the property can be updated? Well, in principle we can call the rest api to update the properties in ways that don't update the self.property.
I grant that it's not so common.

 

Anyway, if you are writing a thermostat you should keep that value in a local/instance variable anyway and update the property with self:updateProperty
There is really no reason to read the self.property for efficiency. 
At start/restart you read the value with getValue, and after that you get the new value user sets with the UI from the UI event (which you call self:updateProperty with)

Yes, hub.getValue(self.id, "heatingThermostatSetpoint") takes ~900 times longer time then self.properties.heatingThermostatSetpoint on a HC3,

the hub.getValue(self.id, "heatingThermostatSetpoint") still only takes ~1ms...

  • Like 1
  • 0
  • Inquirer
  • Posted
    22 hours ago, jgab said:

    Be careful with that. I usually treat the self.property as a cache...
    The reason is that it is set when the QA starts up and is given the current device structure .properties value.
    After that, the self.properties is only updated when we do a self:updateProperty(prop, value) (or an action that results in a self:updateProperty)
    Are there other ways that the property can be updated? Well, in principle we can call the rest api to update the properties in ways that don't update the self.property.
    I grant that it's not so common.

     

    Anyway, if you are writing a thermostat you should keep that value in a local/instance variable anyway and update the property with self:updateProperty
    There is really no reason to read the self.property for efficiency. 
    At start/restart you read the value with getValue, and after that you get the new value user sets with the UI from the UI event (which you call self:updateProperty with)

    Yes, hub.getValue(self.id, "heatingThermostatSetpoint") takes ~900 times longer time then self.properties.heatingThermostatSetpoint on a HC3,

    the hub.getValue(self.id, "heatingThermostatSetpoint") still only takes ~1ms...

    Well i was womdering if there are some methods (undiscovered by me), that avoid using api calls. For example, i want to know a device's role. I need to go for

    Please login or register to see this code.

     

    instead of self.deviceRole..

     

    I brought up the "deviceRole" just as an example, the question goes for other properties too, that we usually get back only by using api calls. 

    I don't know for sure, but i think getting back a devices propertie's values using hub.call(), or self.<whatever> should be many many times faster than getting back them from api calls. Thats why i am asking.

    • 0
  • Inquirer
  • Posted

    @jgabJan, if we do forexample self:updateProperty("model", "v1.0.1") in out onInit() function, doesn't it make an inifinit loop??
    Isn't the updateProperty call restarts tha quckapp, and so it gets into an infinit loop??

    • 0
    Posted
    2 minutes ago, Neo Andersson said:

    @jgabJan, if we do forexample self:updateProperty("model", "v1.0.1") in out onInit() function, doesn't it make an inifinit loop??
    Isn't the updateProperty call restarts tha quckapp, and so it gets into an infinit loop??

    No, self:updateProperty don't restart the QA.

     

    Please login or register to see this code.

    do restart the QA

    • Like 1
    • Thanks 1

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