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. Can someone help me. I have been thinking about how the logic would work and cannot come up with the correct Lua code to make this work correctly. Goal: want the door to unlock when I arrive at home and lock when I leave and send a message (push, email etc..) every time. but if I am home/not home I don't want it to keep locking/unlocking and sending me a message *I already have fibaro looking for my phone to see if I'm present. a global variable keeps a number count present =1 not present = 0 so the logic I came up with is like this: Check Present=0 then lock door and send message check present =0 (still not at home) do nothing check present = 1 unlock door and send message check present = 1 (still at home) do nothing etc... let me know if you have questions or suggestions.
  2. I have an issue trying to make and HTTPS POST request. I am getting "short read" error with the URL "https://api2.magicair.tion.ru/idsrv/oauth2/token" This is my scene: ============================================= --[[ %% properties %% events %% globals --]] local authData = "username=XXX&password=YYY" function doTest() print('Test!') local requestUrl = "https://api2.magicair.tion.ru/idsrv/oauth2/token" local httpClient = net.HTTPClient() httpClient:request(requestUrl, { options = { method = "POST", headers = { ["Content-Type"] = "application/x-www-form-urlencoded", ["Content-Length"] = tostring(authData:len()) }, data = authData, timeout = 5000 }, success = function (response) fibaro:debug (response.data) end, error = function (err) fibaro:debug ("Error: " .. err) end }) setTimeout(doTest, 5*1000) end print('Script start...') doTest() ============================================= I am getting the following in my log: [DEBUG] 15:16:52: Script start... [DEBUG] 15:16:52: Test! [DEBUG] 15:16:52: Error: short read I have been trying to play with headers, data format, timeouts and all parameters I could find, however I always get the same error with the provided URL. Other HTTPS URLS I tried with GET method works just fine. Also I have been trying to do the same with cURL and it works fine with the exact same set of headers and payload (with full credentials string, of course). So the issue is somehow connected with this specific URL: "https://api2.magicair.tion.ru/idsrv/oauth2/token" The Internet is saying that short read problem in HTTPClient request might be related to ciphering protocols mismatch between the client and server. So there could be some parameter regulating this? 2 main versions, which I see: 1. Some tricky param is required to form the correct HTTPS request. 2. Some bug / missing feature in HTTPClient implementation in HC2. Anyway I am stuck and need the help from the community and HC developers. Help!
  3. Hi, Some block did not work as expected, so I converted them to Lua. The general structure of the scenes in Lua is: function tempFunc() the payload code setTimeout(tempFunc, 60*1000); end if (sourceTrigger["type"] == "autostart") then tempFunc() else the payload code end Thus the payload is doubled in code. I changes this to: function tempFunc() payload() setTimeout(tempFunc, 60*1000); end function payload() the payload code end if (sourceTrigger["type"] == "autostart") then tempFunc() else payload() end Any comments?
  4. Hello, does anyone know how I can get OVERCURRENT notification in lua in DIMMER2? Thanks in advance, Regards RB
  5. Witam, jak w LUA sprawdzić czy zostało wysłane powiadomienie o zwarciu na wyjściu Dimmera2? już dwa razy ukradli mi "na żywca" lampy ogrodowe i chciałbym móc wykorzystać to powiadomienie do wywołania alarmu z góry dzięki RB
  6. Hi, I´m writing a couple of VERY SIMPLE LUA Scenes that I have linked to Double Click action of a double switch 2. The scene often works fine, but sometimes, some the turnon or turnoff actions are not executed. (by instance, instead of turning off the 3 lights, only 2 are turnned off, or maybe the vent turnon fails...) Also tried added sleep between commands but the result is the same. Any idea? This is quite frustrating... When I run the scen from the debuger interface, it seems that it works properly... As stated, the code is very simple: (Turn off lights, turn on vent, wait 7 minutes and turn off vent (except if the light were turned on again while the vent is on) fibaro:call(88, "turnOff"); --light off 1 fibaro:sleep(100); fibaro:call(93, "turnOff"); --light off 2 fibaro:sleep(100); fibaro:call(94, "turnOff"); --light off 3 fibaro:sleep(100); fibaro:call(89, "turnOn"); --this is the vent fibaro:sleep(420000); -- wait 7 minutes local bathLightStatus = 0; bathLightStatus = bathLightStatus + fibaro:getValue(88, 'value'); bathLightStatus = bathLightStatus + fibaro:getValue(93, 'value'); bathLightStatus = bathLightStatus + fibaro:getValue(94, 'value'); -- fibaro:debug('Number of bath lights on: ' .. bathLightStatus); if ( bathLightStatus == 0) then -- fanStatus = fibaro:getValue(89, 'value'); -- fibaro:debug('Fan Status ' .. fanStatus); fibaro:call(89, "turnOff"); -- fibaro:sleep(1000); -- fanStatus = fibaro:getValue(89, 'value'); -- fibaro:debug('Fan Status after off ' .. fanStatus); end
  7. Version 1.0.0

    125 downloads

    Virtual device for control of Daikin air conditioners with the SKYFi addon. (untested)
  8. Version 20180525

    309 downloads

    20180525 (Stable) release Added/Changed: - Added some code to the mainloop to detect critical error occurring when a device is forced-removed [ERROR] line 195: attempt to perform arithmetic on a nil value
  9. I try to get some data from a http:request in a LUA scene. I have the following code: local strLonoID = fibaro:getGlobalValue ("LonoID"); print ("LonoID = ", strLonoID) local Temp1 = fibaro:getGlobalValue ("LonoTemp1"); print ("LonoTemp1 = ", Temp1) local http = net.HTTPClient() http:request('http://lonobox.com/api/index.php?id=100003523', { success = function(current) --fibaro:debug(json.encode(current)) --werkt if current.status == 200 then print('Data Receiving: ', current.status) -- werkt print('CurrentData: ', current.data) -- werkt local result = json.decode(current.data) print ('Result :', result) --Local temp2 = result.(["CurrentData"]["200003523"]["temperature"]) --local temp2 = result.200003523.temperature --print ('Temp2 :', temp2) -- else fibaro:debug(current.status) end end }) and i have as output: [DEBUG] 17:13:32: LonoID = 100003523 [DEBUG] 17:13:32: LonoTemp1 = 2 [DEBUG] 17:13:32: Data Receiving: 200 [DEBUG] 17:13:32: CurrentData: [[],{"200003523":{"temperature":"23.2","humidity":"46"}},{"400004105":{"wind-speed":"0.2","wind-gust":"1.5","wind-direction":"SE"}},{"100003523":{"barometer":"1014"}}] [DEBUG] 17:13:32: Result : table: 0x9c98200 I want to store the values in global variables. I do not know how to proceed from here. Thx in advance. Fons
  10. Hi I have recently reconfigured my system, now a big part of my devices got other functions. Everything works well, beside one switch. There is one device, which turning off on random time of the day. I'm considering that I have a scene running, where I forgot to change device id after changes on the system, but I cannot find it. Everything looks fine. Question is: Is there any option to find out, which scene or system process is triggering action on the specific device?
  11. Hello, Is it posible in HC2 LUA to create global functions? I use o lot of functions over and over again and have to include them in every scene Is it possible to create functions in a centralized scene and use them from every other scene? Example: ------------------------------------------------------------------------------------ GlobalFunctions ------------------------------------------------------------------------------------ global function BeepXseconds(x) fibaro:call(42, "turnOn") fibaro:sleep(x * 1000) fibaro:call(42, "turnOff") end global function MyDebug(text, color) -- read GlobalGlob if DebugGlob = true then -- do something with formatting text, add OS.date and add colors fibaro:debug(text) end end ------------------------------------------------------------------------------------ now i can use the global functions in other scenes ------------------------------------------------------------------------------------ scene 161 - TurnAlarmOn ------------------------------------------------------------------------------------ -- do something MyDebug("Turn Alarm on", "red") BeepXseconds(5) -- do something ------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------ scene 254 - Doorbell ------------------------------------------------------------------------------------ -- do something MyDebug("Someone is ringing", "BLUE") BeepXseconds(2) -- do something ------------------------------------------------------------------------------------ AND OFCOURSE I CAN CREATE SCENES AND USE THEM LIKE GLOBAL FUNCTIONS BUT PARSING VARIABLES IS NOT THAT SIMPLE, I THEN HAVE TO USE GLOBAL VARIABLES REAL GLOBAL FUNCTIONS (LIKE A LIBRARY) WOULD BE GREAT !!!
  12. Hello, Is it possible to read the relay state from the Heatit thermostat with LUA? i can read the setpoint, roomtemp, but not if the heating/cooling is on or off fibaro:getValue(50, "value")) >> setpoint fibaro:getValue(51, "value")) >> roomtemp I also tried a lot of the other getValue commands, like 'mode' and 'thermostatState' but nothing happens And of course i can create a scene that calculates the difference between roomtemp and setpoint, so that the relay is on if roomtemp - setpoint > diff but i like to check the real state
  13. Hi, Planning on setting up Qubino 0-10v dimmers with the Fibaro HC2. Does anyone know if these can be used in Lua scenes like the scene activation functionality in the Fibaro Dimmer 2? Thanks
  14. Hi all, I try to build a smart alarm system. I installed on entrance on a apartment a motion sensor. People sometimes pass outside apartment that can cause a false alarm. I like to ask from experts if you can build a basic sence that can count 1 minute after the first trigger and if there is activity/motion to sound alarm. As it is common burglars for security doors need from 30 sec to 5 min to open this kind of doors, in my opinion if someone will stay outside to my door, will not do that for a good reason. I believe that fibaro can give the flexibility that no other alarm system can provide.
  15. Hi, I would like to set a device parameter thru either a virtual device (preferred) or a scene In my example, I have a doorlock (IDLock 101) and would like to set parameter number 1 (autolock mode) The parameter can set the lock to autolock(arm or not armed) or manual (arm or not armed) https://idlock.no/wp-content/uploads/2018/03/IDL-Operational-Manual-EN-v1.3.pdf Is it possible thru LUA or do I need to set it another way? Regards
  16. Hello All, As I try to build a presence detection with BLE, I like to ask if there is a way to poll GPS coordinates of a user by request, overriding the pre-configured time frame. When user is detected from BLE inside range to stop polling and when user is out of BLE range to get a specific time frame for GPS Polling, according to period of day. Any help?
  17. Hi, When building LUA scenes it would be great to have my own utility functions library at hand - not to replicate code, but be able to reuse the code. Like having a global function that does something to strings, or other type conversions. Any idea how to put this (rather obvious for programmers) idea to work on HC2? P.
  18. Good Morning Guys, I need to create a Virtual Device in order to enable/disable some functionality of my devices. Shortly in need to extract the XML, modify a tag value, re-upload the xml. I have understood that using "Net.FHttp" and GET/PUT command im able to RETRIEVE and PUT the XML.... Example: response,status,errorcode = device:GET('URL') Example: response,status,errorcode = device:PUT('URL',XML) But how the entire process can be writed in LUA? 1) How to store in a variable the entire XML extracted using teh GET command? 2) How to replace the xml tag parameter ? ex. from enable to disable 3) How to re-upload the modified XML? Thanks in advnace Regards Gianluca
  19. Hi I recently figured out that my scenes with sending picture to e-mail from a ip camera not working anymore. It stops working around November 2017, I think after update to 4.150 or 4.140. Now running 4.170 on HC2 and command "sendPhotoToUser" not working. Button with camera logo on the device which used to send a snapshot to mail, also doesn't work. Has anyone else same issue? Code which should send a picture looks like this: Exactly the same code coming from block scene, when I making new scene now and converting to lua. --[[ %% properties 874 value %% weather %% events %% globals --]] local startSource = fibaro:getSourceTrigger(); if ( ( tonumber(fibaro:getValue(874, "value")) > 0 ) -- id 874 is triggering device or startSource["type"] == "other" ) then fibaro:call(648, "sendPhotoToUser", "2"); -- 648 is a camera id, 2 is a user id end Camera's settings and plugins/for cameras wasn't changed since this worked.
  20. Hi guys, is there a way to stop the ringing or cancel the call using lua or an api call? Sometimes I just walk to the door and open it. But the intercom keeps ringing. Thanks
  21. Hi, I have recently introduced myself into fibaro lua scenes world, I installed a door/window sensor, it works perfectly but the scene I made keeps the light on all day, without caring about the hour, sunrise, or sunset, so i wanna modified that. I wrote a Lua code for trying to solve this problem, but i don't know if this would work i can't find out the right property, Do I have to send the sensor sleep (when i don't want the lights to turn on during the day) and wake up (during the night)? sensor_puerta= id_device while true do --current_time=os.time() --tcurrent_time=os.date("%t",current_time) tcurrent_time=os.date("%t") c_hour=tcurrent_time.hour c_min=tcurrent_time.min --system hour s_hour= 18 s_min=30 --setting hour for tunning on if ((c_hour < s_hour) and (c_min < s_min)) then fibaro: call(sensor_puerta, "sleep"); --fibaro: call(sensor_puerta, "turn off"); --confirmar parametro else fibaro: call(sensor_puerta, "wake up"); --confirmar parametro end end
  22. I have two Fibaro sensor on my drive one at each end. i am trying to make a scene that says if sensor a is trigged first and then sensor b is trigged turn on lights but if sensor b is trigged first and then sensor a is trigged don't turn on lights not sure how to right it in Lua code
  23. I have used several block scenes to set a weekday variable and also not been able to set the month variable. Have now tried to create a LUA code, that will set my 2 variables with only one scene, but it does not work. Could someone let me know what I am doing wrong please? (This is my first attempt on a LUA written scene) --[[ %% autostart %% properties %% weather %% events %% globals --]] local dag = os.date("%w"); local mnd = os.date("%m"); if(dag == 0) then; fibaro:setGlobal("Ukedag", "Søndag"); elseif(dag == 1) then; fibaro:setGlobal("Ukedag", "Mandag"); elseif(dag == 2) then; fibaro:setGlobal("Ukedag", "Tirsdag"); elseif(dag == 3) then; fibaro:setGlobal("Ukedag", "Onsdag"); elseif(dag == 4) then; fibaro:setGlobal("Ukedag", "Torsdag"); elseif(dag == 5) then; fibaro:setGlobal("Ukedag", "Fredag"); elseif(dag == 6) then; fibaro:setGlobal("Ukedag", "Lørdag"); end; if(mnd == 1) then; fibaro:setGlobal("Maaned", "Januar"); elseif(mnd == 2) then; fibaro:setGlobal("Maaned", "Februar"); elseif(mnd == 3) then; fibaro:setGlobal("Maaned", "Mars"); elseif(mnd == 4) then; fibaro:setGlobal("Maaned", "April"); elseif(mnd == 5) then; fibaro:setGlobal("Maaned", "Mai"); elseif(mnd == 6) then; fibaro:setGlobal("Maaned", "Juni"); elseif(mnd == 7) then; fibaro:setGlobal("Maaned", "Juli"); elseif(mnd == 8) then; fibaro:setGlobal("Maaned", "August"); elseif(mnd == 9) then; fibaro:setGlobal("Maaned", "September"); elseif(mnd == 10) then; fibaro:setGlobal("Maaned", "Oktober"); elseif(mnd == 11) then; fibaro:setGlobal("Maaned", "November"); elseif(mnd == 12) then; fibaro:setGlobal("Maaned", "Desember"); end; The variables that are set:
  24. Hello, 1) Does somebody know what the size limit is for the 'message' variable in Lua sendEmail fibaro:call (2, "sendEmail", subject, message) I am sending automatic generated log files to my email but sometimes i receive nothing, after decreasing the number of lines i receive the mail. 2) And can Fibaro Lua return a error (number or text) in a variable using this sendEmail command? Thanks!
  25. Hello, Is it posible to send text to a cell in a Google spreadsheet from Fibaro Lua? My central heating is a zone-heating controlled bij a Fibaro HC2 with zwave Secure thermostats in every room in my house. The heating works by a central gas boiler and electric Heimeier valves with Fibaro relais I like to log the on/off times (then i can calculate the heating minutes per day) so that i can show it in a graph according to the room temperature and outside temperature. With this information i can make my heating even smarter, i can automatically calculate the starting time to heat in the morning depending on the room and outside temperature to reach a certain temp at 9:00 If sending text to a external document is possible it can be used for a lot of other things: - Temperature logs (pir/smoke sensor) - Room usage (pir) - Usage of devices (koffeemachine, radio, tv, computer, lights, .....) - Graphical views - ......
×
×
  • Create New...