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

Question on data graphics child devices


Question

Posted (edited)

I sее a problem that when you create child of the device by LUA in QApp HC3, in parent device displays a graph of changes of values, but the child - do not. At the same time, there is a "save history" checkbox. What could be the problem?

Edited by matsys

5 answers to this question

Recommended Posts

  • 0
Posted

Welcome to the forum @matsys

 

Graphs in the advanced settings of a device depend on the device type. 

 

Can you tell us more on what you are doing? Share your code?

  • 0
  • Inquirer
  • Posted

    So, i read data from temperature-humidity sensor by Modbus TCP.

     

    I have parent device - temperature sensor and 1 child: humidity sensor

     

    Some code (not full in order not to overload, but the principle itself was clear)

     

    -- Multilevel switch type should handle actions: turnOn, turnOff, setValue
    -- To update multilevel switch state, update property "value" with integer 0-99
    class 'humSM5310'(QuickAppChild)
    function humSM5310:__init(dev)
      QuickAppChild.__init(self,dev)
    end
    function humSM5310:updateValue(data)
      self:updateProperty("value", data.hum)
    end

     

    function QuickApp:updateChildDevices()
      for id,child in pairs(self.childDevices) do -- Update Child Devices
        child:updateValue(data) 
      end
    end

    -- Value is type of float
    function QuickApp:setValue(value)
        --self:debug("multilevel switch set to: " .. tostring(value)) 
        self:updateProperty("value", value)    
    end

     

    -- Setup child

     

    function QuickApp:setupChildDevices()
      local cdevs = api.get("/devices?parentId="..self.id) or {} -- Pick up all Child Devices
      function self:initChildDevices() end -- Null function, else Fibaro calls it after onInit()...

      if #cdevs == 0 then -- If no Child Devices, create them
        local initChildData = { 
          {className="humSM5310", name="Hum sm5351", type="com.fibaro.humiditySensor", value=0},
        }
        for _,c in ipairs(initChildData) do
          local child = self:createChildDevice(
            {name = c.name, type=c.type, value=c.value, initialInterfaces = {}, }, 
            _G[c.className] -- Fetch class constructor from class name
          )
          child:setVariable("className",c.className)  -- Save class name so we know when we load it next time
        end   
      else 
        for _,child in ipairs(cdevs) do
          local className = getChildVariable(child,"className") -- Fetch child class name
          local childObject = _G[className](child) -- Create child object from the constructor name
          self.childDevices[child.id]=childObject
          childObject.parent = self -- Setup parent link to device controller 
        end
      end
    end

     

     

    So, first i create child device - humidity sensor and from time-to-time reload value, and all is ok display, but no graphics on this child device, and parent (temperature) device - have graphics.

    • 0
    Posted

    Device types com.fibaro.humiditySensor don’t have the graphs like for example the temperature, power devices have. 

    • 0
  • Inquirer
  • Posted

    Thanks! Where can I look at all types? Is it listed somewhere?

    • 0
    Posted

    yes, there is, over here:

     

     

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