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

  • 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 6 results

  1. Hi I have this function function getHueLight(id) local hueIP = 'xxx.xxx.xxx.xxx' local huePort = '80' local hueKey = '--------------------------------' local requestUrl = "http://"..hueIP..":"..huePort.."/api/"..hueKey.."/lights/"..id; local httpClient = net.HTTPClient(); httpClient:request(requestUrl, { options = { headers={}, method='GET' }, success = function (response) fibaro: debug (response. data) end, error = function (err) fibaro: debug ("Error:" .. err) end }); end and i want to assign output of this to variable i've tried somthing like this local var = getHueLight(id) but it's get nil value
  2. Hi, I want to know the ID's of all my window/door sensors. But my question is more basic. i.e. ids = fibaro:getDevicesId({interfaces ={"energy"}}) This will give me a list battery powered devices. So I presume something like that: ids = fibaro:getDevicesId({Type ={"door"}}) will give me the id's of my doorsensors. How could if find out the parameters of the getdevicesId() function? Thanks for any hints. Gerhard
  3. I am trying to learn more about functions in lua How to enable a function? This is what i tried already, see below --[[ %% properties 194 value %% events %% globals --]] -- Trigger Management local currentDate = os.date("*t") local startSource = fibaro:getSourceTrigger() --Start of Scene Execution if (startSource["type"] == 'property') then fibaro:debug("Started through property") tempFunc1() -- this is calling the the function if something happens. elseif (startSource["type"] == 'global') then fibaro:debug("Started through variable") tempFunc2() -- this is calling the the function if something happens. elseif (startSource["type"] == "autostart") then fibaro:debug("Started through autostart") tempFunc3() -- this is calling the the function if something happens. elseif (startSource["type"] == "other") then fibaro:debug("Started through other ") --tempFunc4() -- this is calling the the function if something happens. function4() else fibaro:debug("Scene not started, this can only be started through other, property, global or autostart!"); end function tempFunc1() fibaro:debug("test 1"); end I got an error on line 14 ( tempFunc1() -- this is calling the the function if something happens.) when i start the trigger: [DEBUG] 10:23:51: Started through property[DEBUG] 10:23:51: line 14: attempt to call global 'tempFunc1' (a nil value)l value) Why, and how to resolve this ? --- SOLVED ----------------------------------------- Ok i solved my own question: first i have to enable the function tempFunc1() and afterthat he trigger !!! as below... --[[ %% properties 194 value %% events %% globals --]] -- Trigger Management local currentDate = os.date("*t") local startSource = fibaro:getSourceTrigger() function tempFunc1() fibaro:debug("test 1"); end --Start of Scene Execution if (startSource["type"] == 'property') then fibaro:debug("Started through property") tempFunc1() -- this is calling the the function if something happens. elseif (startSource["type"] == 'global') then fibaro:debug("Started through variable") tempFunc2() -- this is calling the the function if something happens. elseif (startSource["type"] == "autostart") then fibaro:debug("Started through autostart") tempFunc3() -- this is calling the the function if something happens. elseif (startSource["type"] == "other") then fibaro:debug("Started through other ") --tempFunc4() -- this is calling the the function if something happens. function4() else fibaro:debug("Scene not started, this can only be started through other, property, global or autostart!"); end
  4. Created a LUA function you can use in a scene to upload data to emoncms.org. toEmonCMS = function(id,value,InputKey) local http = net.HTTPClient() -- CHANGE WRITE API KEY FOR EMONCMS local apikey = '1966dcf7b44xxxxxxxxxxxxxxxxxxx' -- SHOULD NOT BE NECESSARY TO EDIT BELOW THIS LINE -- local url = 'https://emoncms.org/input/post.json?json={' http:request(url .. InputKey .. ':' .. fibaro:getValue(id, value).. '}' ..'&apikey='..apikey, { options = { method = "POST", }, success = function(response) fibaro:debug (response.data) end, error = function(err) fibaro: debug ("Error:" .. err) end }) end toEmonCMS(58,'value','Temperature') Example first 319 is id of device, second power is what value you want to upload, third Power is the InputKey in emoncms site Upload power data toEmonCMS(319,'power','Power') Upload temperature data toEmonCMS(58,'value','Temperature')
  5. Is it possible to check if the virtual device button was pressed in lua? Is there any function for that in lua? I want to code something like this: (If Button "3" of virtual device with an ID of 674 was pressed than a=a+1) for example
  6. 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...