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

  • 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

  1. Hi, Looking for some input into the logic for a scene before I begin to code.... Background - I am looking to determine occupancy both upstairs and downstairs in my house. A lack of occupancy in either floor would then trigger lights/music/etc to be switched off. Lack of occupancy on both floors would assume no house occupancy (with some other checks ) and this can be used to auto-set our house alarm. No movement detected for 30 mins assume no occupancy. I am using my standard alarm PIR's as I can see status of those in my HC2 approach...for first floor... assume no occupancy (uo_occup = "no") 1) PIR trigger in landing starts scene 2) sets up_occup variable to 'yes' 3) start counter 4) recheck every 15 seconds - if PIR =yes then reset counter - if PIR = no then increment counter 5) if counter reaches 120 ( this is 30 mins at one check per 15 seconds) then set up_occupancy = 'no' 6) Scene stops Next breach starts the scene again Some peripheral checks to cover corner cases..... If Alarm = partsetA then up occupancy = yes and hence house occupancy = yes If Alarm = Fullset then house occupancy is no If back or front door is opened then down_occupancy = yes Do people think this would work or are they other approaches ? Thanks -F
  2. Hi, I'm new to Lua and I have read what I could find within the forum discussions. I'm trying to master the basics before I move on and wanted to check from one of the experts that my simple scene is structured as it should be. I have a HC2 and am running the latest FW 4.070 My scene below sets a global variable 'TOD_LightMode' to night, dusk or day depending on the light level from an outside sensor. It runs the scene and then sleeps for 15 mins and repeats. It seems to work okay and I have checked the global variable is available to other scenes and I have used it to trigger other activity. The few questions I have and hopefully somebody can provide advice... 1) do I have all the variables declared correctly ? (I have seen some included in the header in some examples but am not sure what to include there) 2) Is my autostart code correct ? 3) I have a lot of scenes in mind that would be "waiting" scenes. Many people use the while true do or while (someglobalvariable == "somevalue") method. Is there a limitation as to how many of these types of scenes can be running at the same time before it starts to use all the CPU/mem resources ? 4) Is there a simple error checking or logging method that I could/should be using with my scripts. 5) Any other suggestions that would be better practice or make my code more efficient Any help or suggestions very welcome ? Thanks -F Code as follows... --[[ %% autostart %% properties %% globals TOD_LightMode --]] -- Master Scene -- checks the light level to determine if it is night, dusk or day and set a global variable TOD_LightMode -- v1 Frank Smith local sourceTrigger = fibaro:getSourceTrigger(); local startSource = fibaro:getSourceTrigger(); local OutsideLuxSensor = 217 --outside sensor ID for light level if (sourceTrigger["type"] == "autostart") then while true do -- create an infinite loop if tonumber(fibaro:getValue(OutsideLuxSensor, "value")) == 0 then fibaro:setGlobal("TOD_LightMode", "night"); elseif tonumber(fibaro:getValue(OutsideLuxSensor, "value")) > 0 and tonumber(fibaro:getValue(OutsideLuxSensor, "value")) < 50 then fibaro:setGlobal("TOD_LightMode", "dusk"); else fibaro:setGlobal("TOD_LightMode", "day"); end; fibaro:sleep(15*60*1000) end else end
  3. Hi, I have a Thermo-Floor / Heatit Multireg thermostat controlling my floor heating. I was disappointed that it does not support power usage. So I wonder if it would be possible to somehow add to the device with LUA or a separate virtual device that accumulates wattage for the time it was active? I have not done very much LUA coding to know if this would be possible. Is it any point at pursuing this at all? An alternative would be to use an external actuator associated with the thermostat that supports power usage. But it would be more expensive and I'm not sure there is room in the wall box. Regards Stian
  4. Hi, I am new to Fibaro and I own \, for now, just an HCL plus several devices. I would like to create a Virtual device that toggles a predefined Variable. I have tried this: The code behind each button is, for now, just this: The idea is to to activate heating accordingly: This is the scene to turn Heater On This to turn it OFF Obviously it does NOT work.... What Have I done wrong? I cannot export my Virtual Device, is this doable with an HCL? Can I embed LUA coding in a Virtual Device within an HCL? Additional DREAM: can I change the Icon on my VD according to the Button pressed? Is DEBUGGING possible with an HCL? HOW? Many thanks in advance. Roberto
  5. Hi all I am trying to create a scene that changes the setpoint temperature of my Nest thermostat to 10 degrees after windows have been opened. I want the setpoint temperature to be set back to its previous setting once windows are shut. The first part is easy as I have used IFTTT with a Maker channel. But it doesn't look like it's possible to set it back to previous setting through IFTTT. I have the Nest plugin installed which works fine and when I create a new LUA scene, the only action event is 'SetMode' and looks as follows: fibaro:call(9, "setMode", "") Unfortunately there is not too much information available on this so any help would be much appreciated.
  6. Hi, I’m new to LUA and actually newer did the programing, except the pascal on high school J. However I like to learn the new staff, best way for me is learning by doing. I developed many block scenes and converted them into LUA to understand the way it works, but still have some questions I believe if answered, other users will find useful as well. This topic should be for explanation how LUA works. First question what is tempfunc() for and how to use it?
  7. Mayby a stupid question but I cannot find the ID of notifications. I want to send via LUA. I managed to find out de DeviceID via HC2 Toolkit but cannot find the number of notification. syntax of used call: fibaro:call(<ID>, "sendDefinedPushNotification", "<NotificationID>") Many thanks in advance
  8. Hello! I would like to know which char/fontset is used for displaying text in a virtual device? Some of the symbols I use are displayed properly some are not, especially in the android application: local grafik = "▄■▀■▄____▄▄▄▄■▀" mobile APP: webapplication: Is it also possible to change the color of the text? The string.format code does not work... fibaro:debug(string.format('<%s style="color:%s;">%s</%s>', "span", color, message, "span")); Thank's for help
  9. Im trying to control my foscam IP camera (PTZ and other) over the http commands. From any regular browser its a pice of cake. I would like to create virtual device where each button will represent specific command for camera control. I succeeded to create a scene with LUA to execute the commands: --[[ %% properties %% globals --]] local httpClient = net.HTTPClient(); httpClient:request('http://192.168.1.51:88/cgi-bin/CGIProxy.fcgi?cmd=ptzGotoPresetPoint&name=Vchod&usr=AAA&pwd=BBB') However when I use the same code in VD with LUA, it doesn't work. I would like to avoid creating 10 scenes and call the scenes from VD, I would like to execute the code directly from VD. Is it possible? Thanx for any advice.
  10. I'm trying to find a clue on how to group two or more sonos speakers into a combined zone. (eg: kitchen and living room playing the same tracks). Searching the forum doesn't help me so far. Does anyone have any lua-code or code for a button in a virtual device to combine two players to 1 zone? or perhaps a link to en example?
  11. HI, Been wrestling with this for some time now so time to ask for help I'm trying to control my Yamaha Amp, no problem switching input sorces, scenes, on/off etc but when it comes to setting (and later reading) the volume I simply can't get it to work. I'm using a virtual device with a slider. In the LUA-code for the slider I've wrote the script below. When I change the slider the scripts works one in five times, the rest nothing happens. As far as I can tell it reads the slider value OK, the command sent is correct etc. To me it feels like I need to send some end command to the Yamaha but can't figure out how to do it. Any help or feedback is appreciated. Here is the script: local IPYamaha = "192.168.1.67" local pYamaha local cmdYamaha local YamahaValue YamahaValue = 8 * tonumber(_sliderValue_) YamahaValue = YamahaValue - 800 fibaro:log(tostring(YamahaValue)) cmdYamaha = '<YAMAHA_AV cmd="PUT"><Main_Zone><Volume><Lvl><Val>' .. tostring(YamahaValue) .. '</Val><Exp>1</Exp><Unit>dB</Unit></Lvl></Volume></Main_Zone></YAMAHA_AV>' pYamaha = Net.FHttp(IPYamaha,80) response ,status, errorCode = pYamaha:POST('/YamahaRemoteControl/ctrl', cmdYamaha) fibaro:sleep(1000) if errorCode == 0 then fibaro:log('status'..status) else fibaro:log("error") end
  12. 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?
  13. Hi All, This Lua Script does exaclty what I am looking for to use the rain delay in the Sprinkler Panel for what would be a more automated method instead of the built in functionality which is pretty manual (so much for "smart" home) Problem is I have an HCL, so I would need to understand how I program this virtual device without LUA Thanks to Vesternet for the original LUA script http://www.vesternet.com/resources/application-notes/apnt-78#.VgRbcrTJ8UW Any help "translating" please. Thanks
  14. hello i'm stuck i have a raspberry pi that is reading the smart meter and i send the values to a text file the output of that file is shown in a php file like this [{ daldag: 3218, piekdag: 2165, vermogen: 497, gas: 1799.421}] the thing that i want is to read the value with lua into a virtual device to show the power consumption daldag : 3218 = 3218 KWH power consumption on low cost total meter readout piekdag : 2165 = 2165 KWH power consumption on high cost total meter readout vermogen : 497 = 497 Watt current power consumption live reading 10 sec interval refresh gas: 1799.421 = 1799.421 M3 gas meter total readout so the question is how to read the different values with lua many thanks Rex
  15. Hi there. I am running 4.047 on my HC2. I am trying to use this command in LUA to see if there is rain forecast and if I have already set the rain delay to 24 hours then ignore the step. However it does not like the FHttp line.. What am I doing wrong?? The statement seems to work in a virtual device but not in a LUA scene. The error I get is [ERROR] 22:22:46: line 11: attempt to index global 'Net' (a nil value) --]] local sourceTrigger = fibaro:getSourceTrigger(); -- Set authentication HC2 = Net.FHttp("192.168.1.xxx",80) HC2:setBasicAuthentication("admin", "password") -- get data table from the Sprinklers Panel response ,status, errorCode = HC2:GET("/api/panels/drenchers"); jsonTable = json.decode(response); fibaro:debug('Rain Delay Value: ' ..jsonTable.rainDelay); I even tried the following. local HC2 = Net.FHttp("127.0.0.1", 11111); -- get data table from the Sprinklers Panel local response ,status, errorCode = HC2:GET("/api/panels/drenchers"); local jsonTable = json.decode(response); fibaro:debug('Rain Delay Value: ' ..jsonTable.rainDelay); still no joy. This is my entire code. ---------------------------------------------------------------- --[[ %% autostart %% properties 3 WeatherConditionConverted %% globals --]] local sourceTrigger = fibaro:getSourceTrigger(); -- Set authentication local HC2 = Net.FHttp("127.0.0.1", 11111); -- get data table from the Sprinklers Panel local response ,status, errorCode = HC2:GET("/api/panels/drenchers"); local jsonTable = json.decode(response); fibaro:debug('Rain Delay Value: ' ..jsonTable.rainDelay); function tempFunc() local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( ( fibaro:getValue(3, "WeatherConditionConverted") == "rain" ) or ( fibaro:getValue(3, "WeatherConditionConverted") == "storm" ) and (string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "12:01") and ( tonumber(jsonTable.rainDelay == 0 ) ) ) then fibaro:call(319, "pressButton", "2"); fibaro:call(tonumber(fibaro:getGlobalValue("RajIphone")), 'sendPush', 'Sprinkler Delayed by 24 hours'); fibaro:call(2, "sendEmail", "Sprinkler Delay", "Sprinkler Delay by 24 hours"); 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" and ( tonumber(jsonTable.rainDelay == 0 ) ) ) then fibaro:call(319, "pressButton", "2"); fibaro:call(tonumber(fibaro:getGlobalValue("RajIphone")), 'sendPush', 'Sprinkler Delayed by 24 hours'); fibaro:call(2, "sendEmail", "Sprinkler Delay", "Sprinkler Delay by 24 hours"); end end ----------------------------------------------------------------
  16. I have enabled scene activation on my blind modules and I have a scene that triggers as expected when I click once to open my window and again when I click on the same button to stop it from opening any further; the same happens when I click on the right gang to close and pause. The problem is that I need a different outcome when I click once on the left gang to open vs the second time when it pauses the window; similarly for closing and pausing. I can't seem to find a way to determine that the blind has just started opening or whether it has just paused. I have tried value and value2 but they always show as 0. Does anyone have any ideas? PS: positioning does not work as I am controlling windows not blinds and they work differently ;(
  17. Hello, I would download a CSV file with Lua but I can't because HTTP response is application/octet-stream Content-Type. So when I parse the content is zero. I want to address one by one the lines of that file. --[[ %% properties %% globals --]] -- Replace the value with ID of this virtual module selfId=fibaro:getSelfId(); ip = fibaro:get(selfId, 'IPAddress'); ECO = Net.FHttp(ip) local response, status, errorCode = ECO:GET("/protect/download/xdata.csv") fibaro:debug(response) If I take a network trace, although we note that the content is a Content-Type: application / octet-stream GET /protect/download/xdata.csv HTTP/1.1 Host: 192.168.1.10 Connection: keep-alive Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36 Accept-Encoding: gzip, deflate, sdch Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4 HTTP/1.1 200 OK Connection: close Content-Type: application/octet-stream Cache-Control: no-cache ANNEE,MOIS,JOUR,T1_BASE,T1_HCHP,T1_HCHC,T1_EJPHN,T1_EJPHPM,T1_BBRHPJB,T1_BBRHCJB,T1_BBRHPJW,T1_BBRHCJW,T1_BBRHPJR,T1_BBRHCJR,T1_PMAX,T1_ISOUSC,T1_IMAX,Counter1,T2_BASE,T2_HCHP,T2_HCHC,T2_EJPHN,T2_EJPHPM,T2_BBRHPJB,T2_BBRHCJB,T2_BBRHPJW,T2_BBRHCJW,T2_BBRHPJR,T2_BBRHCJR,T2_PMAX,T2_ISOUSC,T2_IMAX,Counter2 2015,1,21,0,437439,233912,0,0,0,0,0,0,0,0,0,45,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2024300, 2015,1,22,0,445749,251266,0,0,0,0,0,0,0,0,0,45,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2024300, Regards,
  18. Hello, My LUA-scenes are not being rescheduled on Home center 2. They run once when I click "start" or "run" but never runs again. This has worked fine before and just seem to have stopped working all of a sudden. Even if I create a new scene with just at debug printout, nothing happens more than once. It might be related to a firmware upgrade, I'm not what version of the firmware that this was running properly on. Now I use the latest version (4.042). Any clues to what's going on and how I can get things going again? BR Erik
  19. How hard can it be to set a value to 30 from 60 ? delay = fibaro:getValue(28, "alarmDelay"); -- Get time fibaro:debug ("exit delay =" ..delay); fibaro:call(28, "alarmDelay", "30"); --set new time delay = fibaro:getValue(28, "alarmDelay"); -- Get new time fibaro:debug ("new exit delay =" ..delay); But i cant change it, It is still 60
  20. Hi Every morning i forget to disarm my permitter (night) alarm. Now I would like to create a scen that does it for me :=) Senario: in the morning between 6-7am monday to friday then motion is detected in the bathroom then disarm So I need some help with he lua cod for the timerange ==================================================== --[[ %% properties 9 value %% globals --]] if ( ( tonumber(fibaro:getValue(9, "value")) > 0 ) -- Motion detected and THIS ===> ( (os.day= monday to friday) and (os.time = 06:00 to 07:00) ); ) then fibaro:call(61, "turnOn"); -- example code for disable permiter... End ====================================================== THX in advance
  21. Hi, I'm trying to learn how to use Lua, but struggling to get my head around it with no examples, if possible could you post a scene on here with a breif description of what it is, ie the ID and what they are, it would be very much appreciated Thanks Ally
×
×
  • Create New...