Welcome to Smart Home Forum by FIBARO
Search the Community
Showing results for tags 'setbasicauthentication'.
Hi all, I am struggling with a weird bug that happens on a very irregular basis (once in weeks, or lately 2 times in 1 week at night). The VD controls my home heating. After is crashes, it gets cold. Sometimes decoding the json string kills my VD 'Main', fatal error: "Expected value but found T_END at character 1". 'User' has admin credentials to access the heating panel. If I deliberatly corrupt username or password, I get the same error. For performance reasons, authentication is done once as 'Main' never ends. Function HeatRoom() runs every minute. It looks like 'panel' from HC2:GET is an empty string once in a while but why? Is it possible for authentication to expire? Any idea about the cause/trigger and a fix? if Once == nil then Username = "User" Password = "Password" HC2 = Net.FHttp( "127.0.0.1" ) -- Access HC2 from inside local Auth = HC2:setBasicAuthentication( Username, Password ) HeatingID = 191 Once = "Done" -- Done only once. end function HeatRoom() panel = HC2:GET( "/api/panels/heating?id=" .. tostring( HeatingID ) ) panel = json.decode( panel ) -- Yields once in a while fatal error: "Expected value but found T_END at character 1". -- etc. end Snippet.lua