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

Temperature display for virtual device


Question

Posted

Hi, does anyone know how I return a temp sensor value into a Quick App Temp sensor device?

 

If I use the below in a QA it returns the temperature in Console but does not display the temp in the Quick App device

print(ipAddress, json.encode(data))

 

any ideas how I can display the temp on a virtual temperature or humidity device?

15 answers to this question

Recommended Posts

  • 0
Posted
23 hours ago, Phenix said:

Hi, does anyone know how I return a temp sensor value into a Quick App Temp sensor device?

 

If I use the below in a QA it returns the temperature in Console but does not display the temp in the Quick App device

print(ipAddress, json.encode(data))

 

any ideas how I can display the temp on a virtual temperature or humidity device?

Please login or register to see this attachment.

Please login or register to see this image.

/monthly_2021_11/image.png.d37fde88920e9fc99bac6a5eafe16af7.png" />

if you annoyed BL-Sensors device please

Please login or register to see this attachment.

  • 0
  • Inquirer
  • Posted

    Thank you for the code.

    I replaced your IP with mine

    local BroadlinkDeviceIP = "192.168.0.41"

    But still returns 0c???

     

    I know that the temp and humidity sensor work as I wrote a small return function

     

    Please login or register to see this image.

    /monthly_2021_11/image.png.8cfa516add7eb67ecbff391e403a0fe8.png" />

     

     

     

     

    • 0
  • Inquirer
  • Posted

    on init

     

    Please login or register to see this image.

    /monthly_2021_11/image.png.7c3d3ee8f0f73d951b3b05ab53e53966.png" />

    I defaulted the original Broadlink FQA as I previously split out temp and humidity by changing the code getSensorsT and getSensorsH - but changed it back to getSensors and print Temp,Humidity

     

    image.png.d841944e6e220618b18e448db7f5c6e8.png 

    • 0
  • Inquirer
  • Posted

    I do not get the data to return any value on your FQA

     

    Please login or register to see this attachment.

    • 0
    Posted

    no guess

    Please login or register to see this attachment.

    • 0
  • Inquirer
  • Posted

    do I need to add variables and did you make any changes to the main Broadlink code?

    What version of Broadlink hub are you using?

     

    Regards

    • 0
    Posted
    1 hour ago, Phenix said:

    do I need to add variables and did you make any changes to the main Broadlink code?

    What version of Broadlink hub are you using?

     

    Regards

    why r u asking me? 

     

    >What version of Broadlink hub are you using?

    what has that to do with it?

     

    you asking why graph is empty.

    idk why graph if correct values passed to QA.

     

    can you share face of QAs

    like

    Please login or register to see this image.

    /monthly_2021_11/image.png.ed705992f64ee320b35715700af8a7cb.png" />

    • 0
  • Inquirer
  • Posted

    Please login or register to see this image.

    /monthly_2021_11/image.png.6be53abfe597e8ab48ad3a15503191aa.png" />

    image.png.ca495e3ddf56b4ac41372e1c36bb2511.png

    local BroadlinkDeviceIP = "192.168.0.41"

    function QuickApp:onInit()
        self:debug("QuickApp:onInit")

        self:initChildDevices({
            ["com.fibaro.temperatureSensor"] = BroadlinkSensor,
            ["com.fibaro.humiditySensor"] = BroadlinkSensor,
        })

        -- Print all child devices.
        self:debug("Child devices:")
        for id,device in pairs(self.childDevices) do
            self:debug("[", id, "]", device.name, ", type of: ", device.type)
        end

        local cdevs = api.get("/devices?parentId=" .. self.id) or {} -- Pick up all my children
        if #cdevs == 0 then
            self:createChilds()
        end

        setInterval(
            function()
                self:updateSensors()        
            end,
           -- 1000 * 60 * 1
           1000 * 60 * 1
        )
        self:updateSensors()
    end

    function QuickApp:sensorsData(ipAddress, data)    
        for id, child in pairs(self.childDevices) do 
            child:updateValue(data) 
        end
    end

    function QuickApp:updateSensors()
        fibaro.call(fibaro.getDevicesID({name="Broadlink hub"})[1], "getSensors", BroadlinkDeviceIP, plugin.mainDeviceId)
    end

    function QuickApp:createChilds()
        local child = self:createChildDevice({
            name = "Temperature",
            type = "com.fibaro.temperatureSensor",
        }, BroadlinkSensor)

        self:trace("Child device created: ", child.id)

        local child = self:createChildDevice({
            name = "Humidity",
            type = "com.fibaro.humiditySensor",
        }, BroadlinkSensor)

        self:trace("Child device created: ", child.id)
    end

    class 'BroadlinkSensor' (QuickAppChild)

    function BroadlinkSensor:__init(device)
        QuickAppChild.__init(self, device) 
        self:debug("BroadlinkSensor init")   
    end

    function BroadlinkSensor:updateValue(data)
        if self.type == "com.fibaro.temperatureSensor" then
            self:updateProperty("value", data.temperature)
        elseif self.type == "com.fibaro.humiditySensor" then
            self:updateProperty("value", data.humidity)
        end
    end

    • 0
  • Inquirer
  • Posted

    Please login or register to see this image.

    /monthly_2021_11/image.png.3fbc31e2086add2b6913f83fbbf8de9b.png" />

    • 0
    Posted

    Please login or register to see this code.

     

    • 0
    Posted

    show me 

    function QuickApp:getSensors(ipAddress, action)
    from BL hub(main)
    • 0
  • Inquirer
  • Posted
    function QuickApp:getSensors(ipAddress)
        local device = RM4(ipAddress)
        device:auth(
            function(authResult, errCode, payload)
                -- print("AUTH", authResult, errCode, dump(payload))
                if authResult then
                    device:checkTemperature(
                        function(actionResult, errCode, payload)
                            local temp = payload[0x6 + 1] + ( payload[0x7 + 1] / 100 )
                            local humidity = payload[0x8 + 1] + ( payload[0x9 + 1] / 100 )
                            print(temp, humidity)
                        end
                    )
                else
                    self:error("Can`t auth device " .. ipAddress)
                end
            end
        )
    end
    • 0
    Posted

    Ha ha ha

    meow

    replace please

     

    Please login or register to see this code.

     

    • 0
  • Inquirer
  • Posted

    Excellent - now working - thank you

     

    Replace

    function QuickApp:getSensors(ipAddress)

     

    With

    function QuickApp:getSensors(ipAddress, action)

     

    And add

     if tonumber(action) then
                                fibaro.call(action, "sensorsData", ipAddress, {temperature = temp, humidity = humidity})

     

     

    Excellent work - thank you for your help - looks like another video ;)

     

     

    image.png.a8d69f1ef459975be43ca4a12fc91c3f.png

    • Thanks 1
    • 0
  • Inquirer
  • Posted

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Please login or register to see this attachment.

     

     

    @10derThank you for your assistance and support-  I have credited you

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