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


Recommended Posts

Posted
16 minutes ago, jgab said:

Well, the message

Instantiating object Kiss Zoli Home (Netatmo Livingroom Module)_Temperature[21.10.2024] [09:21:37]

is not an error. It's just logged when it creates the Lua object from QwikAppChild

Yes but why? Every time i get the http response i am getting these logs..Shouldt this happen only when object is instantiated, so when I start or restart the QA?

  • Topic Author
  • Posted (edited)
    13 minutes ago, Neo Andersson said:

    Yes but why? Every time i get the http response i am getting these logs..Shouldt this happen only when object is instantiated, so when I start or restart the QA?

    Yes only start/restart. When you call 

    Please login or register to see this code.

    Is your QA crashing and restarting?

    Put a log message in the beginning of :onInit()

     

    Edited by jgab
    Posted
    10 minutes ago, jgab said:

    Yes only start/restart. When you call 

    Please login or register to see this code.

    Is your QA crashing and restarting?

    Put a log message in the beginning of :onInit()

     

    Okay, i think there is something with the logic..When HTTP fails, there is no data from where the myChildren table is created, there will be something linked to this..i will investigate deeper..thanks so far

    • 1 month later...
    Posted (edited)

    @jgab Jan i am using your class QwikAppChild  for child device handling. I need to add battery interface to the parent device, but if I call

    Please login or register to see this code.

     

    it starts an infinit loop of instantiating my quickapp..

     

    How to add battery interface to the parent?

     

     

    Here is the rough logic of the code

     

    Please login or register to see this code.

     

     

    Please login or register to see this image.

    /monthly_2024_12/image.png.1d0014cf840dfede45f24cbb0c479a9b.png" />

    Edited by Neo Andersson
    Posted
    1 minute ago, Neo Andersson said:

    @jgab Jan i am using your class QwikAppChild  for child device handling. I need to add battery interface to the parent device, but if I call

    Please login or register to see this code.

     

    it starts an infinit loop of instantiating my quickapp..

     

    How to add battery interface to the parent?

     

    Please login or register to see this link.

     

    I might be wrong :D But it should only be called the first time the QA starts.
    so if you can do a check before doing the self:addinterfaces you can avoid this? :)
    Since it makes the QA restart everytime it adds a interface :D

    Or if we can get a check on if the battery interface does exist on the parent device by api.get in and if statment 🤔

     

     

     

    Posted
    27 minutes ago, Brors94 said:

     

    I might be wrong :D But it should only be called the first time the QA starts.
    so if you can do a check before doing the self:addinterfaces you can avoid this? :)
    Since it makes the QA restart everytime it adds a interface :D

    Or if we can get a check on if the battery interface does exist on the parent device by api.get in and if statment 🤔

     

     

     

    Yes, probably you are right, but as this QA will be encrypted and installed on several systems, i cant do that hardcoding..There is some possibility i am sure, but thanks for the suggestions.

     

    • Like 1
  • Topic Author
  • Posted (edited)

    Yes, a QA restarts if you call addInterface.
    Check if

    Please login or register to see this code.

    You can also check fibaroExtra's function QuickApp:addInterfaces(interfaces)

    that is a more general approach.

    Edited by jgab
    • Like 1
    • Thanks 1
    Posted (edited)
    On 2/6/2023 at 1:18 PM, jgab said:

    Please login or register to see this code.

    @jgab Jan, using Qwickapp class, i have created several sensors, and one bindary switch..Now i want to run some action when the switch is pressed, but i cant figure out how to define a function  of turnOn, and turnOf to the child binary switch. I was following your examplem above, but thats not what i should use, this is creating a metthod for the class itself, and not for the child..

    Would you please assist a bit?

    Edited by Neo Andersson
  • Topic Author
  • Posted
    9 hours ago, Neo Andersson said:

    @jgab Jan, using Qwickapp class, i have created several sensors, and one bindary switch..Now i want to run some action when the switch is pressed, but i cant figure out how to define a function  of turnOn, and turnOf to the child binary switch. I was following your examplem above, but thats not what i should use, this is creating a metthod for the class itself, and not for the child..

    Would you please assist a bit?

    Please use 

    Please login or register to see this link.


     

    Please login or register to see this code.

     

    Posted (edited)
    5 hours ago, jgab said:

    Please use 

    Please login or register to see this link.


     

    Please login or register to see this code.

     

    @jgab Jan, when i use this approach, itt will try to bind a trunOn function to every child device in my table..or not? Probably it will no harm nothing, as calling turnOn on a sesnsor will do nothing, but i am curious, is this the right approach?

     

    This is my class, it should create 4 different child devices 

     

    Please login or register to see this code.

     

    and the i call in onInit like this

     

    Please login or register to see this code.

     

    and the goal is, that after the childs are created, i want to set some action for when user turns on that child switch. Also this question goes for the case when there are more child switches. User presses one of them, how will the class know which of them was pressed, and what action should be run inside that particular child's turnOn function..This is a bit that i need some explanation for to get it in the right way..Sorry

    Edited by Neo Andersson
  • Topic Author
  • Posted (edited)
    24 minutes ago, Neo Andersson said:

    @jgab Jan, when i use this approach, itt will try to bind a trunOn function to every child device in my table..or not? Probably it will no harm nothing, as calling turnOn on a sesnsor will do nothing, but i am curious, is this the right approach?

     

    This is my class, it should create 4 different child devices 

     

    Please login or register to see this code.

     

    and the i call in onInit like this

     

    Please login or register to see this code.

     

    and the goal is, that after the childs are created, i want to set some action for when user turns on that child switch. Also this question goes for the case when there are more child switches. User presses one of them, how will the class know which of them was pressed, and what action should be run inside that particular child's turnOn function..This is a bit that i need some explanation for to get it in the right way..Sorry

    Well, it's no harm. The methods will be like QuickApp methods for the children. Like having a temperature sensor QA that has a function QuickApp:turnOn() method... not relevant, but no harm.

     

    However, in general I would argue that you should have different child classes for different fibaro types. My experience is that the code actually becomes simpler as you don't need a lot of "if self.type == "com.fibaro.temperatureSensor" ...." etc in the generic ShellyWally_Class... Instead each child class does whatever it should do with the update data you send it.

    Edited by jgab
    Posted
    7 minutes ago, jgab said:

    Well, it's no harm. The methods will be like QuickApp methods for the children. Like having a temperature sensor QA that has a function QuickApp:turnOn() method... not relevant, but no harm.

     

    However, in general I would argue that you should have different child classes for different fibaro types. My experience is that the code actually becomes simpler as you don't need a lot of "if self.type == "com.fibaro.temperatureSensor" ...." etc in the generic ShellyWally_Class... Instead each child class does whatever it should do with the update data you send it.

    Okay, so i will keep it in one, like i have, but what whould we do if we had forexample 2 child binary switches..How would you differentiate them? Like if i will have Switch1 and Switch2 created as child in my ShellyClass. I want to call a http when Switch1 is pressed, and want to call another Http when switch2 is pressed. How ?

  • Topic Author
  • Posted (edited)

    You give each child the data it needs to do its specific task.

    Ex.
     

    Please login or register to see this code.

     

    Here I put that data in the same children table with the name, type, and class. You could also put it in another table.

    Each child will have it's uid (the key in the children table) in the property self._uid.
    Use that to look up the specific data that each binarySwitch needs to do its job...
     

    Edited by jgab
    • Thanks 1
    Posted (edited)
    36 minutes ago, jgab said:

    Here I put that data in the same children table with the name, type, and class. You could also put it in another table.

    Each child will have it's uid (the key in the children table) in the property self._uid.
    Use that to look up the specific day that each binarySwitch needs to do it's job...

    @jgab Jan, this is throwing error..

     

    Please login or register to see this attachment.

     

    but thats not true. The device exists..

    Please login or register to see this image.

    /monthly_2024_12/image.png.d1bcfd6d4261965e7926d11ac7aa60fc.png" />

     

     

    Sorry, found the problem. myChildren table was local..that was the reason i think

     

     

    Edited by Neo Andersson
  • Topic Author
  • Posted (edited)

    You can't declare myChildren locally in createMyChildren() and expect to access the variable in function ShellyWalli_Class:__init(device)...

    Look how I forward declared the variable in my example.

     

    So the child's initial method crashed and it was not created and couldn't be found when the QA tried to lookup the child in it's self.childDevices table - therefore the error message you got (even if the device structure existed in the UI list)

    Edited by jgab
    Posted
    14 minutes ago, jgab said:

    You can't declare myChildren locally in createMyChildren() and expect to access the variable in function ShellyWalli_Class:__init(device)...

    Look how I forward declared the variable in my example.

     

    So the child's initial method crashed and it was not created and couldn't be found when the QA tried to lookup the child in it's self.childDevices table - therefore the error message you got (even if the device structure existed in the UI list)

    Thanks Jan, meanwhile i have found the problem, so i did update my topic right away..thank you

    Posted (edited)

    @jgab Jan, there is a bit more challenging task here. Can we create a child device of type thermostat? 

    Probably not..

    So the goal is, after I crated the child sensor and child switch i need to create a child (or not child if its not possible) thermostat device that will consist from my previously created sensor and switch.

    Is this task even doable?

    This is probably a noway task, because in the swagger i can see, that the thermostat has no dedicated parameter for sensor and heating switches..All the devices are in one parameter named devices, so this makes it even more challenging..

     

    Edited by Neo Andersson
  • Topic Author
  • Posted

    Yes you can create thermostat child. Why not?
    It's quite common that when you try to map an external device to fibaro's device types you need to represent the device with several fibaro types. Ex. Hue or Ikea motion sensor are typically also temperature and lux sensors so a single motion device need to be represented as 3 fibaro types (children), com.fibaro.motionSensor, com.fibaro.tempratureSensor, com.fibaro.lightSensor.

    In theory we could create 1 child of type motion sensor and the add the new "custom UI" for children to show the temperature and lux value together with the motion value. However, that "combined" device would not be easily used from ex. block scenes as they would see it as just a motion sensor.... there is also no good place to store the other values (temp and lux) in the device property structure so we need to put it in ex. quickvars...

    If it's just that you need extra UI switches (and methods) you could get away with adding a custom UI with those extra buttons for the thermostat. Alternatively, create separate binary switch children representing those switches (and give the children similar names so that one understand that they belong together)

     

    I think that thermostats have selector for cooling/heating/echo etc and some kind of slider for the value?

    Posted
    47 minutes ago, jgab said:

    Yes you can create thermostat child. Why not?
    It's quite common that when you try to map an external device to fibaro's device types you need to represent the device with several fibaro types. Ex. Hue or Ikea motion sensor are typically also temperature and lux sensors so a single motion device need to be represented as 3 fibaro types (children), com.fibaro.motionSensor, com.fibaro.tempratureSensor, com.fibaro.lightSensor.

    In theory we could create 1 child of type motion sensor and the add the new "custom UI" for children to show the temperature and lux value together with the motion value. However, that "combined" device would not be easily used from ex. block scenes as they would see it as just a motion sensor.... there is also no good place to store the other values (temp and lux) in the device property structure so we need to put it in ex. quickvars...

    If it's just that you need extra UI switches (and methods) you could get away with adding a custom UI with those extra buttons for the thermostat. Alternatively, create separate binary switch children representing those switches (and give the children similar names so that one understand that they belong together)

     

    I think that thermostats have selector for cooling/heating/echo etc and some kind of slider for the value?

    In my case the biggest challange is, that the child thermostat should be created in a way so its sensor will be the child sensor (created by my QA) and the switch (also created by my QA)..this is very challenging, and i think even impossible, thats why i raised this question..

     

    Please login or register to see this image.

    /monthly_2024_12/image.png.af69f9c39431ed24813510a4d22d1cf8.png" />

    Posted

    @jgab yeah and here is the cherry on the cake..

     

    Creating a thermostat type child device will end up in a device without any UI control...oh ...Fibaro...Neither in web UI nor in mobile app...

    Tried with all available types, 

    com.fibaro.hvacSystemAuto,
    com.fibaro.hvacSystemHeat,
    com.fibaro.hvacSystemCool

     

    Please login or register to see this image.

    /monthly_2024_12/image.png.a8e4d78cb1ab4b3de57652ea2a4e2e6b.png" />

     

     

     

     

    So this is another dead end.

     

     

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

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