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

Help with QAs..


Question

Posted

Hi Everyone,

 

I have just managed to go from HC2 to HC3 and im having problems to port a Froggit weather station (using Ecowitt API) to use QA.

The HC2 implementation was to query Ecowitt API and store all information into global variables but since i now understand i should instead use QA and child devices to store these instead, i have looked into several tutorials but for me its a bit messy and i cannot fully grasp the "QA" way yet.

 

So i was hoping if a kind soul could help me (Im getting old) with a simple way of creating a QA with a child device and then how to create the label, updated with values?

 

The net.HTTPClient works so i can fetch all devices and values but is there someone who can explain how i create, initialize, a child device and also how i populate it from the API response? 

 

BR

Recommended Posts

  • 0
  • Inquirer
  • Posted

    Many many thanks for this tinman!

     

    Now it works :)

    • 0
    Posted (edited)

    You can't have this

    Please login or register to see this code.

    same key overwrites, so all child com.fibaro.temperatureSensor becomes HMatsal.
    In this case it doesn't matter I guess as they have more or less the same implementation.

    Fibaro's implementation of this is one reason you may want to implement your own loadChildDevices...

    Edited by jgab
    • Like 1
    • 0
  • Inquirer
  • Posted

    Yes, i saw that:

        self:debug("Init child devices")
        self:initChildDevices({
            ["com.fibaro.temperatureSensor"] = TMatsal,
            ["com.fibaro.temperatureSensor"] = TBasement,
        })

     

    [2025-11-13] [09:11:01] [DEBUG] [QUICKAPP4220]: Init child devices

    [2025-11-13] [09:11:01] [DEBUG] [QUICKAPP4220]: TBasement init

    [2025-11-13] [09:11:01] [DEBUG] [QUICKAPP4220]: TBasement init

    • 0
  • Inquirer
  • Posted

    Oh, and im now struggling with updating the values..

     

     for key,value in pairs(self.childDevices) do
                self:debug("Key: " ..key.." Value: " ..value.name)
                if value.name == 'Basement Temperature Sensor' then
                    self.childDevices[self.TBasement]:updateValue(jsonTable.data.indoor.temperature.value)
                end
     
    [2025-11-13] [09:35:01] [DEBUG] [QUICKAPP4220]: Key: 4222 Value: Basement Temperature Sensor
    [2025-11-13] [09:35:01] [ERROR] [QUICKAPP4220]: QuickApp crashed
    [2025-11-13] [09:35:01] [ERROR] [QUICKAPP4220]: main.lua:386: attempt to index a nil value (field '?')
    • 0
  • Inquirer
  • Posted (edited)

    Ok, sorry for spamming.. I managed to do some changes which seems to work except for the child devices not being updated..

     

    I only create a "base" child class that only supports temperature sensors. Then i reuse it for the child instances (Temp sensors).
    Now it doesnt complain when trying to update child devices but unfortunately, they dont get updated..

     

    class 'Temperature' (QuickAppChild)
    function Temperature:__init(device)
        QuickAppChild.__init(self, device)
        self:debug("Temperature init")
    end
    function Temperature:updateValue(value)
        self:updateProperty("value", value)
    end
     
    self:initChildDevices({
            ["com.fibaro.temperatureSensor"] = TempSensors,
        })
     
    if api.get("/devices/"..self.id).enabled then
            self:updateView("label0", "text", "Last measurement on: "..os.date("%d.%m.%y %X"))
            tbl = hub.getGlobalVariable("EcowittTable")
            jsonTable = json.decode(tbl)
            self:debug("Temp basement: " ..jsonTable.data.temp_and_humidity_ch3.temperature.value)
            for key,value in pairs(self.childDevices) do
                self:debug("Key: " ..key.." Value: " ..value.name)
                if value.name == 'Matsal Temperature Sensor' then
                    self:debug("Trying to update value for "..key.." to: ".. jsonTable.data.indoor.temperature.value)
                    self.childDevices[key]:updateValue(jsonTable.data.indoor.temperature.value)         
                end
                if value.name == "Basement Temperature Sensor" then
                    self:debug("Trying to update value for "..key.." to: ".. jsonTable.data.temp_and_humidity_ch3.temperature.value)
                    self.childDevices[key]:updateProperty("value", jsonTable.data.temp_and_humidity_ch3.temperature.value)
                end
     
     
     
    [2025-11-13] [11:45:55] [DEBUG] [QUICKAPP4220]: Checking if childs are available..
    [2025-11-13] [11:45:55] [DEBUG] [QUICKAPP4220]: Child devices already present
    [2025-11-13] [11:45:55] [DEBUG] [QUICKAPP4220]: TempSensors init
    [2025-11-13] [11:45:55] [DEBUG] [QUICKAPP4220]: TempSensors init
    [2025-11-13] [11:45:55] [DEBUG] [QUICKAPP4220]: Child devices:
    [2025-11-13] [11:45:55] [DEBUG] [QUICKAPP4220]: [ 4222 ] Basement Temperature Sensor , type of: com.fibaro.temperatureSensor
    [2025-11-13] [11:45:55] [DEBUG] [QUICKAPP4220]: [ 4221 ] Matsal Temperature Sensor , type of: com.fibaro.temperatureSensor
    [2025-11-13] [11:45:56] [DEBUG] [QUICKAPP4220]: Temp basement: 18.0
    [2025-11-13] [11:45:56] [DEBUG] [QUICKAPP4220]: Key: 4222 Value: Basement Temperature Sensor
    [2025-11-13] [11:45:56] [DEBUG] [QUICKAPP4220]: Trying to update value for 4222 to: 18.0
    [2025-11-13] [11:45:56] [DEBUG] [QUICKAPP4220]: Key: 4221 Value: Matsal Temperature Sensor
    [2025-11-13] [11:45:56] [DEBUG] [QUICKAPP4220]: Trying to update value for 4221 to: 22.1
     
    Edited by 747
    • 0
  • Inquirer
  • Posted

    It was quite simple.. i needed to cast the json value to a number and then it worked..

    • 0
    Posted
    On 10/30/2025 at 3:15 PM, tinman said:

     

    i have created QA for Froggit / Eccowitt, however haven't released it to public. Generally only for DP2000 Pro 7-in-1 version,

    Please login or register to see this link.


    but of course it can support other models too. What not yet supported is automatic detection of extra attached sensors, so when need to add them extra in code.

    I will send you PM with the QuickApp. 

     

     

     

    Hi @tinman, I also have an Ecowitt Wittboy station with Ecowitt DP.2000. Is it possible to test your QuickApp on my HC3 as well?
    Thank you very much.

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