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!



Smart Home Forum by FIBARO Team

Search the Community

Showing results for tags 'Lua'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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


  • Scenes
  • Virtual Devices
  • Quick Apps
  • Icons

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start






Website URL





  1. I'd like to see an optional parameter added that will disable triggering scenes when setting a global variable in LUA. The HTTP API has this functionality albeit in reverse (default to false) Something along the lines of: fibaro:setGlobal( varName, value [, invokeScenes] ) Where: varName: The name of the global variable value: The new value of the global variable invokeScenes: Boolean, default true
  2. Hi Wondering why we don't have resizable txt boxes in the LUA scripting page ? It's not often I code in LUA in HC2, but when I do .. gee it's annoying Thanks, al.
  3. Hi Fibaro users Many of us are experiencing a very strange bug since a long time that kill our scenes. This bug appear without any reasons after several hours/days without any problems, it's a major issue that give us the feeling that the Fibaro box is not reliable. Just to give you my example of yesterday evening 19:41:06 : [DEBUG] 07:07:03: Module Parents (128) pressButton to 1 [DEBUG] 07:07:03: Module Espace Famille (123) pressButton to 1 [DEBUG] 07:07:03: Date : 2017/03/07 07:07:03 [DEBUG] 19:41:06: line 35: unexpected character @ character: 1 0:1 [�] line: [DEBUG] 19:41:06: � [DEBUG] 19:41:19: Redémarrage auto du script Réveil Matin (106): 2017/03/07 19:41:19 [DEBUG] 07:00:00: Réveil matin enclenché [DEBUG] 07:00:09: Ouverture volets matin phase 1 [DEBUG] 07:00:15: Module Parents (128) pressButton to 2 I saw several subjects in this forum with the same problem but without any clear answer to the problem, for examples : https://forum.fibaro.com/index.php?/topic/22964-script-terminated-garbage-in-log-script-error-line-incorrect/#comment-100942 https://forum.fibaro.com/index.php?/topic/22658-scene-keeps-quitting-on-error/#comment-99007 https://forum.fibaro.com/index.php?/topic/23955-vdscene-weather-status-v10b-netatmo-weather-station-rain-wind/#comment-108439 https://forum.fibaro.com/index.php?/topic/22801-issue-in-scene-after-update-to-41/#comment-99865 As you can see in the sample, i'm using (like many of us) another scene to check that the main scene is still active or not, and if not, to restart it. In french forums, users have done a specific virtual device to check scenes and vd. It seems it's a Lua bug that can be solved only by Fibaro. Could someone in Fibaro check that point to finally solve it one time for all? PS : Sorry for my english...
  4. Hi, I have external lights. I use geolocation with ifttt. When I arrive near my house my lights turn on automatically. But it must light up when it is dark. At sunset. I created one variable : I created 3 scenes. First scene : --[[ %% autostart %% properties %% weather %% events %% globals --]] local sourceTrigger = fibaro:getSourceTrigger(); function tempFunc() local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( ( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == fibaro:getValue(1, "sunsetHour")) ) ) then fibaro:setGlobal("ext", "1"); end setTimeout(tempFunc, 60*1000) end if (sourceTrigger["type"] == "autostart") then tempFunc() else local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( startSource["type"] == "other" ) then fibaro:setGlobal("ext", "1"); end end My first scene Sets my variable to 1 when the sun goes down My second scene sets my variable to 0 when the sun rises. --[[ %% autostart %% properties %% weather %% events %% globals --]] local sourceTrigger = fibaro:getSourceTrigger(); function tempFunc() local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( ( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == fibaro:getValue(1, "sunriseHour")) ) ) then fibaro:setGlobal("ext", "0"); end setTimeout(tempFunc, 60*1000) end if (sourceTrigger["type"] == "autostart") then tempFunc() else local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( startSource["type"] == "other" ) then fibaro:setGlobal("ext", "0"); end end And My third scene that executes the lighting of my lights when ext = 1 and that the sun goes down. --[[ %% properties %% weather %% events %% globals ext --]] local startSource = fibaro:getSourceTrigger(); if ( ( tonumber(fibaro:getGlobalValue("ext")) == tonumber("1") ) or startSource["type"] == "other" ) then fibaro:call(32, "turnOn"); end I have a problem, It makes day or night my scene of lighting my lights work all the time. I don't understand. One idea ? if you can help me please. Thx.
  5. hi guys, is there a way to expand the tiny lua editor window? I find it very hard to code in there. thanks for any hints. kro
  6. Hi, I have two functions in a scene that I call one after the other function1 - create global variable if it doesn't exist (through the api) function2 - write some data to the global variable the second function will fail as the 'create variable' hasn't been completed by the time I try to write to it. I can add a delay or a check that the 'variable is not nill' (ie it exists) in function2 but it still fails to execute correctly I think I recall seeing that a http request in a scene will not always run in the order of the scene ? is this correct or something else here at play. If so has anybody found a way within a single scene to create a variable on the fly and then save data to it successfully. As a last resort I was thinking about having the scene run once to create the table, call a second instance of itself and kill the first instance. I'm not sure if this would even work but it seemed like a very inefficient workaround even if possible I have seen many virtual device examples of creating a variable on the fly and saving data to it but none from a scene Thanks -f @jompa68, @petergebruers, @Sankotronic
  7. Hi, I've been looking to find a way to mimic a dawn awakening using a RGB strip driven by a fibaro RGB module @petergebruers provided some RBG / HSL translation and I've been working on the colour sequence that is stored in an array It's essentially burnt orange -> yellow -> blue'ish -> almost white There area few of the transitions I am not 100% happy with but I was looking for a few people to test what I have done to date and see if I am on the right path The scene has a sleep of 1 second but in reality I'd probably have it close to 10 or 15 which would give an overall start to finish time of -10 minutes to aid a gradual wakeup Comment out line 7 if you don't use a HomeTable Line 61 contains the reference to the RGB strip, amend as required. @andyp - You expressed an interest in this before All feedback welcome - Feel free to tweak the colors or just pass back comments Thanks -f -- DAWN SIMULATOR USING AN RGB STRIP -- THANKS TO petergebruers FOR THE BULK OF THE CODE -- BETA --[[ %% properties %% events %% globals --]] local jT = json.decode(fibaro:getGlobalValue("HomeTable")) --Hue_2_RGB( v1, v2, vH ) function Hue_2_RGB(v1, v2, vH) if ( vH < 0 ) then vH = vH + 1 end if ( vH > 1 ) then vH = vH - 1 end if ( ( 6 * vH ) < 1 ) then return ( v1 + ( v2 - v1 ) * 6 * vH ) end if ( ( 2 * vH ) < 1 )then return ( v2 ) end if ( ( 3 * vH ) < 2 ) then return ( v1 + ( v2 - v1 ) * ( ( 2 / 3 ) - vH ) * 6 ) end return ( v1 ) end function RGB(H,S,L) if s==0 then return L*255,L*255,L*255 end local var_2 if ( L < 0.5 ) then var_2 = L * ( 1 + S ) else var_2 = ( L + S ) - ( S * L ) end local var_1 = 2 * L - var_2 return 255 * Hue_2_RGB( var_1, var_2, H + ( 1 / 3 ) ) , 255 * Hue_2_RGB( var_1, var_2, H ), 255 * Hue_2_RGB( var_1, var_2, H - ( 1 / 3 ) ) end local R,G,B=RGB(120,0.5,0.5) fibaro:debug("R "..R.." G "..G.." B "..B) R,G,B=RGB(120,0,0.5) fibaro:debug("R "..R.." G "..G.." B "..B) local dawnHSL={ {0,0,0}, -- turn off. {0.03,0.67,0.012}, {0.04,0.68,0.013}, {0.06,0.69,0.014}, {0.08,0.70,0.015}, {0.09,0.71,0.016}, {0.10,0.73,0.017}, {0.12,0.75,0.018}, {0.13,0.77,0.019}, {0.15,0.79,0.020}, {0.19,0.83,0.022}, {0.20,0.84,0.023}, {0.21,0.86,0.024}, {0.22,0.87,0.023}, {0.23,0.89,0.026}, {0.25,0.91,0.028}, {0.41,0.90,0.033}, {0.41,0.88,0.034}, {0.41,0.86,0.035}, {0.42,0.85,0.036}, {0.43,0.83,0.037}, {0.44,0.81,0.038}, {0.44,0.79,0.038}, {0.44,0.78,0.040}, {0.45,0.77,0.041}, {0.45,0.75,0.042}, {0.44,0.73,0.043}, {0.46,0.72,0.044}, {0.46,0.70,0.045}, {0.47,0.69,0.046}, {0.47,0.67,0.047}, {0.48,0.66,0.048}, {0.49,0.63,0.049}, {0.50,0.61,0.050}, {0.51,0.58,0.051}, {0.52,0.56,0.052}, {0.53,0.53,0.053}, {0.54,0.51,0.054}, {0.55,0.48,0.055}, {0.56,0.46,0.056}, {0.58,0.44,0.057}, {0.59,0.42,0.058}, {0.59,0.39,0.059}, {0.59,0.37,0.060}, {0.60,0.35,0.061}, {0.60,0.32,0.062}, {0.60,0.28,0.063}, {0.60,0.24,0.064}, {0.61,0.22,0.065}, {0.61,0.20,0.066}, {0.61,0.18,0.067}, {0.61,0.16,0.068}, {0.61,0.15,0.069}, {0.61,0.14,0.070}, {0.61,0.13,0.071}, {0.61,0.12,0.072}, {0.60,0.11,0.073}, {0.60,0.10,0.074}, {0.60,0.09,0.075}, {0.60,0.08,0.076}, {0.60,0.07,0.077}, {0.60,0.05,0.078}, {0.60,0.05,0.079}, {0.60,0.05,0.080}, {0.60,0.05,0.082}, {0.60,0.04,0.083}, {0.60,0.03,0.084}, {0.60,0.02,0.085}, {0.60,0.01,0.086}, {0.60,0.02,0.087}, {0.60,0.01,0.088}, } fibaro:debug(string.format("R G B ")) for k,v in pairs(dawnHSL) do local R,G,B=RGB(v[1],v[2],v[3]) fibaro:debug(string.format("%05.1f %05.1f %05.1f",R,G,B)) fibaro:call(jT.master_bedroom.LEDLight, "setColor",math.floor(R+0.5), math.floor(G+0.5), math.floor(B+0.5), "0") fibaro:sleep(1000) end
  8. Hi! I am working on my first VD and I want to change the text of a button during runtime. fibaro:call(SelfId, "setProperty", "ui.Button21.Label", "new text") fibaro:call(SelfId, "setProperty", "ui.Button21.value", "new text") None of the calls on top is working, I am a little bit frustrated Change a slider value or a text of a label is working fine Any help is welcome ...
  9. Hi, Changing this post a little to generate some discussion around good morning sequences and what people are currently or planning to do. I'm hoping to get some ideas myself and may also help some people just starting this journey.. I'll start - This is my good morning sequence and it's triggered on weekdays at 6:40 and 8:00 on weekends by a scheduler derived from @Sankotronic Main Scene code. Music control is with the sonos-htt-api and TTS is AWS Polly. I have some sleep steps that I removed to allow some actions to finish before others start or just to provide seperation. Group 4 music zones upstairs using sonos api presets, select zones, radio station and play at zero vol Change radio station if station not available Set home mode (This may be redundant) Set sleepstate to Awake mode Switch ON Satelite Box Raise vol in master bedroom slowly to preset level Raise music vol in landing room slowly to preset level Raise music vol in kids1 room room slowly to preset level Raise music vol in kids2 room room slowly to preset level Set alarm to UNSET TTS Morning Greeting (weather, temp etc) - Master Bedroom Switch main bathroom mirror light on for kids TTS Morning Greeting (weather, etc)- kids1 room TTS Morning Greeting (weather, etc)- kids2 room Wait for motion trigger in kitchen and switch on kitchen spotlights Slowly raise the other lights to preset levels Slowly raise the kitchen, hall and playroom music to preset levels What else are other people doing ? Thanks -f
  10. Hi, I have some Merten/Schneider Eletric radio push button "switches" I would like to use as trigger for turning on and off lights in a room but I do not know what code I would need to use for this to work. The push button in question is Schneider Eletric WDE002903/ Merten MTN5051-0000. Has anyone used this kind og buttons in their Fibaro HC2 system and/or is able to give input on what code is needed to use this as a trigger? Thanks for all help, Kristoffer Merten MTN5051-0000.pdf
  11. Hi, I have been working to automate more of my morning routine and wanted to share what I have to date Questions, ideas, comments, refinements welcome -f --[[ %% properties %% events %% globals --]] local jT = json.decode(fibaro:getGlobalValue("HomeTable")) if (fibaro:countScenes()>2) then fibaro:abort() end fibaro:call(jT.vd.SonosPresets, "pressButton",2) -- Group zones, select radio and play at zero vol fibaro:sleep(5000) -- sleep 5 seconds for preset to complete fibaro:call(jT.vd.SonosPresets, "pressButton",16) -- Change radio station if station not available fibaro:sleep(5000) -- sleep 5 seconds for channel selection fibaro:setGlobal( "House_Mode", "HOME") -- set home mode (This may be redundant) fibaro:setGlobal(sleepState, sleepStateMapping.Awake) -- Set sleepstate to Awake fibaro:call(jT.vd.MediaSourcePresets, "pressButton",3) -- Switch ON Sat Box fibaro:call(jT.vd.SonosPresets, "pressButton",13) -- raise vol in master bedroom slowly fibaro:sleep(3000) -- sleep 30 seconds fibaro:call(jT.vd.SonosPresets, "pressButton",14) -- raise vol in landing room slowly fibaro:sleep(3000) -- sleep 30 seconds fibaro:call(jT.vd.SonosPresets, "pressButton",11) -- raise vol in twins room slowly fibaro:call(jT.vd.SonosPresets, "pressButton",12) -- raise vol in franks room slowly fibaro:sleep(30000) -- sleep 30 seconds fibaro:call(jT.vd.AlarmManagement, "pressButton",16) -- Set alarm to UNSET fibaro:sleep(5000) -- sleep 5 seconds fibaro:call(jT.vd.SonosTTS, "pressButton",14) -- Morning Greeting (weather, temp etc) - Master Bed fibaro:call(jT.bathroom.MirrorLight, "turnOn") -- main bathroom mirror light on fibaro:sleep(30000) -- sleep 30 seconds fibaro:call(jT.vd.SonosTTS, "pressButton",15) -- Morning Greeting (weather, etc)- Twins Room fibaro:sleep(20000) -- Sleep for 20 seconds to let greeting finish fibaro:call(jT.vd.SonosTTS, "pressButton",16) -- Morning Greeting (weatherm, etc)- Franks Room fibaro:sleep(900000) -- sleep 15 mins fibaro:call(jT.vd.LightsPresets, "pressButton",21) -- Kitchen Morning Lights scene
  12. Hoping someone can shed some light on this... Trying to send a HTTPS GET request to an AWS API Gateway endpoint. Here's the Lua code (obviously I've removed any privileged information for the purposes of posting here): httpClient = net.HTTPClient(); httpClient:request ( 'https://**********.execute-api.eu-west-1.amazonaws.com/****/***********', { options = { method = "GET", headers = { ['x-api-key'] = '*****************************' } }, success = function (response) fibaro:debug (response.data) end, error = function (err) fibaro:debug ("Error:" .. err) end }) I get an 'Error:Transport endpoint is already connected' message in the debug window. That's not a response from the API (no requests get logged on the AWS side, so the HC2 isn't getting as far as making the request at all.) If I try making a HTTPS request to another URL (like Google for example) it works with no issue. Also I know the API endpoint works, because I can call it from CURL and it does exactly what I expect. It's just from a scene. Seems like others have had the same issue, specifically with AWS API Gateway. Anyone know how to get this to work? Cheers, Dan
  13. Hi, I must confess that I use only "value", "lastBreached", "turnOn" and "turnOff" properties and commands for z-wave devices in my scenes. I don't actually know what "log" and "logTemp" and the others are. They may be very useful, but I cannot find any documentation for them. Are there any? Has anyone tried to figure out what they are, and maybe made a list?? Fredrik
  14. Witam Prośba do zespołu projektantów systemu. Może już czas na usprawnienie edytora skryptów LUA ? Można by dodać kilka nowych funkcji ( występujących w innych, popularnych edytorach ) takich jak: ctrl+g - skocz do linii numer ... ctrl+f - wyszukaj frazę ...... ctrl+h - zamień frazę .... na nową .... ctrl+s - zapisz poprawki ctrl+F1 - okno z pomocą - opis funkcji biblioteki fibaro pozycjonowanie kursora ( x, y ) - jest numeracja wierszy, brak numeracji kolumn własny dobór kolorystyki "elementów" skryptu (komentarzy, funkcji, łańcuchów znakowych, liczb itd. ) Wiem, że to nie jest potrzeba pierwszej kolejności ale wielu z nas aby dokonać zmian kopiuje skrypt, przenosi go do innego edytora i tam robi poprawki. Następnie poprawiony skrypt ponownie wkleja do edytora HC2. Usprawnienie edytora HC2 poprzez dodanie tych kilku funkcji wyeliminowałoby ten zbędny "zabieg".
  15. Hello A few months ago my virtual device for my engine heater became very slow and sometimes it doesn't work at all. Sometimes it gets better if i reboot the HC2 but it´s not funny when it´s -30 C and I get late to work because the car wont start and there is no way to be sure if it will work or not the next morning. Is this a known problem and is there a way to read the logfiles on the HC2? The diagnostics panel doesn't say much. The VD has been working great for several months before it became slow/not working. It might have happened after an upgrade. The controlled device works if i manually set i to active. Several other LUA scripts also became non working after an upgrade (cant remember if it happened at the same time) but I got them working just by changing something, save, change back and save again. I also get "to many instances" on other LUA scripts but not on the engine heater. Maybe they overload the HC2 and make it slow? I attached the VD and the scripts. LightsTimerToManyInstancesNotWorking.txt -- a timer that will turn off the lights if any of the two devices is on for more than xx minutes Motorvärmare_V-vfib-json -- The virtual device EngineHeaterLUA.txt -- the script for the VD LightsTimerToManyInstancesNotWorking.txt Motorvärmare_V.vfib.json EngineHeaterLUA.txt
  16. I really have a feeling someone will reply and i feel stupid... but.. How do you call a scene so it will start from a VD? fibaro:call(id,'start') doesn't work, and i can't really see examples for it.
  17. What is the syntax of sonos "text-to-speech" function in lua?
  18. Hi HC2 guru's Would a scene with a xxx value in the header/properties or a VD main loop be more efficient (ie use less resources) if I wanted to use a sensor (motion, light, humidity) to trigger an action. I find some of my sensors don't always react to a scene header trigger and in a vd. I think I could also exert a better level of control with repeat triggers with a vd but I wanted to make sure that this approach wouldn't impact the HC2 excessively Thanks -f
  19. Hi, i'm trying to execute this call using lua on the hc2 ws://<spc_web_gateway_host>:<port>/ws/spc/ Any idea how this could be done. thanks frank
  20. Hi, Just spotted the new UR weather device after the 4.11 upgrade It seems pretty accurate for my location can this be queries using lua or through the API Thanks Frank
  21. Apologies for the newbie question but, is there a LUA IDE application / tool already available, or does everyone tend to use the one they feel comfortable with?
  22. So I have a Good Morning Scene, and it executes other scenes.. I am struggling with understanding if lua waits for return of a scene or fires in parallel? The problem presents as this:- My good morning scene sets some globals, and executes scenes to switch alarms off and turn heating on (via scenes) etc.. then it builds a json table and puts it into a predefined Global... after that is calles a final scene that reads the global and TTS's it to speakers.. Problem is, half the time it seems to be reading the last updated speech body, and not the one that has just been set in the global.. is this a sequencing thing? or issue with globals? should I use a regular global and not a predefined one? I even tried to chain the scenes being called from good morning by nesting setTimeout functions..
  23. Dear All, I want to get into learning LUA. It seems that this is the right way to move forward if anyone is to use the HC2 seriously. However, as a newbie (relatively) to programming, I want to first understand if I need to learn other languages besides LUA in order to get the most out of the HC2. Any advice on where I should start this adventure?
  24. Hi there, I'm a developer but I'm fairly a newbie with LUA language and I'm having some problems undestanding the scope of the variables/functions, or maybe I'm just writing some garbage code... I need your help I want to use the native LUA function "load()" to evaluate a string and let it parse it as LUA code. I'm following LUA 5.2 documentation ( http://www.lua.org/manual/5.2/manual.html#pdf-load ) to use function, but I keep getting this error "attempt to call global "load" (a nil value) and I can't solve it. Here's my chunk of code: And here's the error Btw I'm using load() to make sure mainloop code is called right after button press, and not after 2/3 secs. Hope someone can help me out =) Thank you!
  25. Hi, I have implemented @cag014 HomeTable to track the device ID's of my HC2 the table structure is like this office = { Light=33,Temp=1186,Motion=1251,Lamp=720,rcSonos=1 }, Landing_Stairs = { stairsLight=92,landingLight=168,rcSonos=1 }, scene = { MainScene=614,AlarmControl=598,rebootHC2=593,goodMorning=463,goodNight=331,LeavingHome=483,welcomeHome=488,quietMorning=499,kidsToBed=490,plaroomTvOn=580,firstFloorMusicOn=579,firstFloorAllOff=578, hallSceneControl=519,StairsLight30=556,GateOpen5=526,GateOpenHold=361,GateOpenClose=425,DumpEventLog=565,PlayroomOff=617 }, vd = { AlarmManagement=881,TVPresets=1545,SonosTTS=1452,LightPresets=1534,HouseModeExt=1538,SonosPresets=1536,RackTempMngt=1453,MediaSourcePresets=1567,JhomeTable=1566,GateControl=1537,GarageControl=1559 }, I can update the whole table but was wondering if it was possible to update a specific vale such as "scene.AlarmControl" in the example I posted above. Any helpful code snippets gratefully accepted thanks -f
  • Create New...