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


Search the Community

Showing results for tags 'order'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • FIBARO Community
    • FIBARO Portal and Forum policy
    • FIBARO
    • Say hello!
    • Off-topics
  • FIBARO Update
    • FIBARO System Update
    • FIBARO Mobile Update
  • FIBARO Community Support
    • Scenes and Interface
    • FIBARO Products
    • FIBARO Mobile
    • FIBARO HomeKit
    • FIBARO Assistant Integrations
    • Other Devices / Third-party devices
    • Tutorials and Guides
    • Home Automation
    • Suggestions
  • FIBARO Społeczność
    • FIBARO
    • Przywitaj się!
    • Off-topic
  • FIBARO Aktualizacja
    • FIBARO System Aktualizacja
    • FIBARO Mobile Aktualizacja
  • FIBARO Wsparcie Społeczności
    • Sceny i Interfejs
    • FIBARO Urządzenia
    • FIBARO Mobilnie
    • FIBARO HomeKit
    • Integracja z Amazon Alexa i Google Home
    • Urządzenia Firm Trzecich
    • Poradniki
    • Automatyka Domowa
    • Sugestie

Categories

  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Facebook


Google+


Skype


Website URL


WhatsApp


Country


Gateway/s


Interests

Found 1 result

  1. Hi I have a problem to understand why my lua-code not working as i expected. See first this (properly working) test-lua-scene and the debug-result: --[[ %% properties %% globals --]] globalmessage = " " -- function funcSections() local typename = "Sections" fibaro:debug(globalmessage .. typename) end; function funcRooms() local typename = "Rooms" fibaro:debug(globalmessage .. typename) end; function funcDevices() local typename = "Devices" fibaro:debug(globalmessage .. typename) end; -- fibaro:debug("before call function funcDevices--------------------") globalmessage = "Now call function funcDevices: " funcDevices(); -- fibaro:debug("before call function funcSections-------------------") globalmessage = "Now call function funcSections: " funcSections(); -- fibaro:debug("before call function funcRooms----------------------") globalmessage = "Now call function funcRooms: " funcRooms(); As expected first was the function "funcDevices" performed. Second the function "funcSections". And then at last the function "funcRooms". And now for my scene, which does not work as expected (code and result): --[[ %% properties %% globals --]] globalmessage = " " doneanswer = " " selHelpDRS = "{" Dm, Rm, Sm = 0, 0, 0; function funcDevices() local typename = "Devices" fibaro:debug(globalmessage .. typename) local http = net.HTTPClient() local urlIPP = 'http://127.0.0.1:11111' local urlAPI = '/api/devices' http:request(urlIPP..urlAPI, { options = { method = 'GET' }, success = function(jsonraw) local jssonrawlen = string.len(jsonraw.data) local jsontab = json.decode(jsonraw.data) local i1 = 0 local i1m = 0 selHelpDRS = selHelpDRS .. 'D:{' for k,v in pairs(jsontab) do i1m = i1m + 1 end for i1 = 1, i1m do local id = tonumber(jsontab[i1].id) local roomID = tonumber(jsontab[i1].roomID) local saveLogs = tostring(jsontab[i1].properties.saveLogs) or nil if ( roomID > 0 ) then if ( saveLogs == "true" ) then Dm = Dm + 1 if Dm > 1 then selHelpDRS = selHelpDRS .. ',' end selHelpDRS = selHelpDRS .. Dm ..':'.. jsontab[i1].id end end end selHelpDRS = selHelpDRS .. '}' fibaro:debug("selHelpDRS=" .. selHelpDRS) fibaro:setGlobal("selHelpDRS", selHelpDRS) end, error = function(errorcode) fibaro:debug("error=" .. errorcode) end}) http = nil doneanswer = "yes" end; function funcRooms() local typename = "Rooms" fibaro:debug(globalmessage .. typename) local http = net.HTTPClient() local urlIPP = 'http://127.0.0.1:11111' local urlAPI = '/api/rooms' http:request(urlIPP..urlAPI, { options = { method = 'GET' }, success = function(jsonraw2) local jssonraw2len = string.len(jsonraw2.data) local jsontab = json.decode(jsonraw2.data) local i1 = 0 local i1m = 0 selHelpDRS = selHelpDRS .. ',R:{' for k,v in pairs(jsontab) do i1m = i1m + 1 end for i1 = 1, i1m do local id = tonumber(jsontab[i1].id) if ( id > 0 ) then Rm = Rm + 1 if Rm > 1 then selHelpDRS = selHelpDRS .. ',' end selHelpDRS = selHelpDRS .. Rm ..':'.. jsontab[i1].id end end selHelpDRS = selHelpDRS .. '}' fibaro:debug("selHelpDRS=" .. selHelpDRS) fibaro:setGlobal("selHelpDRS", selHelpDRS) end, error = function(errorcode) fibaro:debug("error=" .. errorcode) end}) http = nil doneanswer = "yes" end; function funcSections() local typename = "Sections" fibaro:debug(globalmessage .. typename) local http = net.HTTPClient() local urlIPP = 'http://127.0.0.1:11111' local urlAPI = '/api/sections' http:request(urlIPP..urlAPI, { options = { method = 'GET' }, success = function(jsonraw3) local jssonraw3len = string.len(jsonraw3.data) local jsontab = json.decode(jsonraw3.data) local i1 = 0 local i1m = 0 selHelpDRS = selHelpDRS .. ',S:{' for k,v in pairs(jsontab) do i1m = i1m + 1 end for i1 = 1, i1m do local id = tonumber(jsontab[i1].id) if ( id > 0 ) then Sm = Sm + 1 if Sm > 1 then selHelpDRS = selHelpDRS .. ',' end selHelpDRS = selHelpDRS .. Sm ..':'.. jsontab[i1].id end end selHelpDRS = selHelpDRS .. '}' fibaro:debug("selHelpDRS=" .. selHelpDRS) fibaro:setGlobal("selHelpDRS", selHelpDRS) end, error = function(errorcode) fibaro:debug("error=" .. errorcode) end}) http = nil doneanswer = "yes" end; -- fibaro:debug("before call function funcDevices--------------------") globalmessage = "Now call function funcDevices: " doneanswer = "no" funcDevices() repeat fibaro:sleep(100) until doneanswer == "yes" ; -- fibaro:debug("before call function funcRooms----------------------") globalmessage = "Now call function funcRooms: " doneanswer = "no" funcRooms() repeat fibaro:sleep(100) until doneanswer == "yes" ; -- fibaro:debug("before call function funcSections-------------------") globalmessage = "Now call function funcSections: " doneanswer = "no" funcSections() repeat fibaro:sleep(100) until doneanswer == "yes" ; See the order of statements in the program. I would expected, first the function "funcDevices" was performed. Then, the second function "funcRooms" is performed. And last the function "funcSections". [DEBUG] 12:20:50: before call function funcDevices-------------------- In principle, the program is working properly. But the wrong order in run the functions de facto can not be explained to me: Order of call's: D R S = direction de facto: S R D Order of call's: R S D = direction de facto: S R D Order of call's: R D S = direction de facto: R S D Order of call's: S R D = direction de facto: S R D Here's someone who can tell me why my desired order is not complied with by the Fibaro-LUA-system? What should I do to make it work the way I want it?
×
×
  • Create New...