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

youless virtual device won't update after a while


Question

Posted

Hi all,

 

I found a virtual device to read out my youless power meter. One problem, the HC2 stops updating it after a while. when rebooting the hc2 it works.

 

Below is the code, is this correct? maybe to many open sessions after a while in the hc2?

 

If i use the iOS app of the youless or the webpage it keeps updating.

 

--[[

%% properties
%% globals
--]]
local data
fibaro:debug("start")
if (nano == nil) then
  nano = Net.FHttp("192.168.11.250",80)
 
end
response, status, errorcode = nano:GET("/a?f=j")
fibaro:debug(response)
jsonTable = json.decode(response)
cnt = jsonTable.cnt
pwr = jsonTable.pwr
lvl = jsonTable.lvl
fibaro:log(pwr)
fibaro:debug(cnt)
fibaro:debug(pwr)
fibaro:debug(lvl)
 
-- deviceid 32 is my youless device ID
fibaro:call(32, "setProperty", "ui.lbl181.value", cnt.." kWh")
fibaro:call(32, "setProperty", "ui.lbl182.value", pwr.." Watt")
fibaro:call(32, "setProperty", "ui.lbl183.value", lvl.."%")
-- fibaro:call(32, "setProperty", "ui.lbl184.value", dev.." ")
fibaro:sleep(10*500)
 
 
anyone got's an idea?
 

7 answers to this question

Recommended Posts

  • 0
Posted

Hi Barend

 

Try this else below nano = Net.FHttp("192.168.11.250",80) and end at the end öf the code.

Please login or register to see this code.

second suggestion to try

I have a simular code where I used POST instead of GET in  response, status, errorcode = nano:GET("/a?f=j")

  • 0
Posted

Why do you want this to run every 5 seconds? (fibaro:sleep(10*500))

 

PS. the else is not correct, it will never run the first time like this.

  • 0
Posted

for sure it will work. Maybe not the first cycle, but from there it stays up and running.

 

See the code of a VD that I have running now for two months

Please login or register to see this link.

  • 0
  • Inquirer
  • Posted

    I would like to run it every 5 sec for a accurate power readout. Like the app and the website does

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

    • 0
  • Inquirer
  • Posted

    Mr. Jack it works perfect! Thanks a lot!

    • 0
  • Inquirer
  • Posted

    Mr Jack why do you prefer post? What is the difference?

    • 0
    Posted

    I used POST because GET didn't work. So that's why I prefered POST 

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" /> 

    Please login or register to see this image.

    /emoticons/default_icon_redface.gif" alt=":oops:" />

    Glad that it works now.

    Guest
    This topic is now closed to further replies.
    ×
    ×
    • Create New...