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

an other youless VD problem


barend121

Question

using the VD from youless (power readout) after a while it stops and de debug view shows this:

 

 

[DEBUG] 00:31:33: start
[DEBUG] 00:31:33: {"cnt":"61945,508","pwr":206,"lvl":0,"dev":"","det":"","con":"OK","sts":"(37)","raw":0}
[DEBUG] 00:31:33: 61945,508
[DEBUG] 00:31:33: 206
[DEBUG] 00:31:33: 0
[DEBUG] 00:31:41: start
[DEBUG] 00:31:41: {"cnt":"61945,509","pwr":205,"lvl":0,"dev":"","det":"","con":"OK","sts":"(29)","raw":0}
[DEBUG] 00:31:41: 61945,509
[DEBUG] 00:31:41: 205
[DEBUG] 00:31:41: 0
[DEBUG] 00:31:49: start
[DEBUG] 00:32:10:
[ERROR] 00:32:10: line 20: Expected value but found T_END at character 1

 

 

 

This is the code and I tried to if then else out the null value, but apparently its not a null value to handle. Anyone a idea? Code is below and many thanks!

 

--[[
%% properties
%% globals
--]]
 
local data
fibaro:debug("start")
if (nano == nil) then
 nano = Net.FHttp("myserver",80)
 
else
 
response, status, errorcode = nano:GET("/a?f=j")
fibaro:debug(response)
 
if response == nil then debug('response is leeg') else
    
    
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(5000)
end 
  
end
  
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

The response is empty, try:

 

if response == nil or response == "" then debug('response is leeg') else

 

 

And add, just to be sure:

fibaro:debug(status)

fibaro:debug(errorcode)

Link to comment
Share on other sites

  • 0
  • Inquirer
  • great! I just added the extra code and let's wait for the error

    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" />

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • put the wait on 500 (half second) and after a few minutes the devices crashed and a 503 went on. 

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • I fixed it with some code a few months ago and here to share: 

     

    --[[
    %% properties
    %% globals
    --]]

    local data
    fibaro:debug("start")
    -- change IP address to your address!
    if (nano == nil) then
     nano = Net.FHttp("192.168.11.250",80)

    else

    response, status, errorcode = nano:GET("/a?f=j")
    fibaro:debug(response)
    -- if response==" " then response = '{"cnt":"61945,001","pwr":516,"lvl":1,"dev":"","det":"","con":"OK","sts":"(47)","raw":0} '
    if response == nil or response == "" 
       then 
       fibaro:debug("response is empty, values are set to zero")
        cnt="0"
        pwr="0"
        lvl="0"
    --    response="{"cnt":"61950,318","pwr":599,"lvl":0,"dev":"","det":"","con":"*","sts":"","raw":0} " 
    --    fibaro:debug(status)
    --    fibaro:debug(errorcode)
        else
    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.." ")

        end
        fibaro:sleep(5000)

    end
      

     

    Also put the virtual devices as an attachment with this post. !

     

    have fun with it!

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    The only thing that's missing here is how to add this with a password protected youless. Any idea?

    Link to comment
    Share on other sites

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