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. A bit embarrassed to ask for advice on this, but I seem not to be able to understand the structure of simple IF-tests in HC2 Scenes, regardless whether these are created in the Block editor or LUA. I need an IF test with the following structure: ....IF ((a AND b) OR (a AND c)) THEN.... Due to the lack of parantheses, I am not able to understand the logical structure of the resulting statement, which in my mind seems confusing ...IF ((a AND b OR c AND b), I use this code to save electricity on my snow melting mats by twice a day testing whether weather conditions has recently set the variable SNOW to YES in which case mats are turned on for two hours (morning and afternoon) and the variable set back to NO. Seems now my mats turn on twice a day (at times "a" and "c") regardless of the the variable ("b"). Are there any "paranthesis" conventions in LUA I have not understood ?
  2. Hello! Sorry, but I'm looking for a complete LUA reference to control the Fibaro heat controller (and the other). Usually there is such an overview, so that one does not have to spend much time to program a control of the devices via try and error. Where did fibaro hide this? Please do not say that I can retrieve the functions in the LUA Editor module list - I know that. I am concerned with the description of the functions and their parameters. Thank you!
  3. Hi, It would be great to have a LUA function collection (maybe as a new Panel?) where we could store reusable functions, making them globally available. I'm doing a lot of custom automation and ended up having a collection of functions that get copy/pasted in scenes but as any developer would find, this is very error prone and makes maintenance extremely problematic. It would be great if we could create new functions as part of a collection namespace and have them available in all scenes. Any change to one of the functions would propagate to all usages. As a MVP for this feature, even a simple editor somewhere where we could drop all functions would be fine, as long as those functions are available in scenes. If there is a better way of currently achieving this, please let me know and close this topic. Much appreciated, Romeo
  4. Hi, Does anyone has a smart idea/code to get the device ID/Name of the device which triggered the alarm? Preferable a solution with flexible device detection, meaning, without the need to store the ID's in static tables in code. Thank you in advance!
  5. Hi, I am using HC-2 to configure all my Home Automation system. I have created Virtual device to control IR devices. As to show case Lable I need to code using Lua. Can any one tell me what's wrong with following Lua code. local hc = fibaro:getSelfId(); local ip = fibaro:getValue (hc, 'IPAddress'); local port = fibaro:getValue (hc,'TCPPort'); tcpSocket = Net.FTcpSocket (ip,port); fibaro:debug(hc); fibaro:debug(ip); fibaro:debug(port); tcpSocket:setReadTimeout(3000); tcpSocket:write("sendir,1:1,1,36337,1,1,95,33,16,16,16,16,16,32,16,32,32,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,32,16,16,32,16,16,16,4651\r"); tcpSocket:disconnect(); fibaro : call(hc, "setProperty", "ui.Label1.value","20°C"); For debugging purpose, I have used socket tester. On it, some time I am able to receive string, some time not. Some time socket connection remain open. Can any one help me. Is there any possibility to have problem with router? AC_Temp.vfib
  6. Good morning Dear, I want to start with the lua programming and I can not find a way to do it, especially to solve these 2 problems, which seem simple but I can not find the solution: 1- I tried with block scenes to light 2 exterior lights 15 minutes before sunset and turn off 5 minutes after sunrise. For this, create 2 scenes 1 to turn on the lights and others to turn them off. The shutdown scene works correctly and leave it in block mode. I have the problem in lighting the lights at night, the only way to turn it on is if I deactivate the scene and turn it on (I DO NOT KNOW WHY I HAVE IT AS AUTOMATED). Attached the scene of the shutdown is the same as the ignition, except that the ignition I put that if it is night and the lights are off then they turn on 2- The other scene is with the Door Windows to turn on the lights when they open, the problem is that when it remains open the door does not turn off the lights. For that create another scene that when it detects that the door is open more than 5 minutes to turn off the Light, the problem I had is that if it does not close it turns on and off every 5 minutes. Thank you very much! Best regards!!!
  7. Dear colleagues, does anybody know how to create scene in LUA for switching a heating panel to the manual mode?
  8. Hello guys! I come from a *nix background and would like to push changes to my LUA scripts to the HC2 without having to copy/paste into a web console. This also makes it a lot easier to have everything under source control. Has anyone taken the time to create scripts for this?
  9. Hi, I need an as complete list as possible of device actions that you may envoke in Lua that takes an additional argument. (That is, not "turnOn", because this is the entire command.) These are the ones that I have found in when going through my devices: "setValue" "setSetpointMode" "setThermostatSetpoint" (2 arguments) "setMode" "setFanMode" "setVolume" "setInterval" "setSlider" (2 arguments) "setProperty" (2 arguments) "pressButton" Have I missed some command? Please note that I need only Actions that a device can perform, not all calls you can make on a device to ask it about its state. Fredrik
  10. Community, I use a keypad with tags with a Fibaro binary senso to switch mij alarm on and off. Somebody made me a LUA script for that. When I present a tag the alarm will switch on or off. This is the script: --[[ %% properties 245 value %% weather %% events %% globals --]] local startSource = fibaro:getSourceTrigger(); -- 2 streepjes is commentaar fibaro:debug(fibaro:getGlobalValue("Alarmstatus")) if ( ( tonumber(fibaro:getValue(245, "value")) > 0 ) -- keypad activated and ( fibaro:getGlobalValue("Alarmstatus") == "uit" ) ) then fibaro:setGlobal("Alarmstatus", "aan"); elseif ( ( tonumber(fibaro:getValue(245, "value")) > 0 ) -- keypad activated and ( fibaro:getGlobalValue("Alarmstatus") == "aan" ) ) then fibaro:setGlobal("Alarmstatus", "uit"); end fibaro:debug( fibaro:getValue(245, "value")) fibaro:debug(fibaro:getGlobalValue("Alarmstatus")) fibaro:sleep(3500) fibaro:abort() My problem is that I get "too many instances". I guess I need to include the following line: "maxRunningInstances": 2, But I have no clue how and where. Is there anybody that could and would tell me how to do so? It would be highly appreciated!
  11. Hi All, I am using my fibaro motion sensor for multiple purposes. For one of them I need it to have a high sensitivity, however, for others I need it to have a lower sensitivity (otherwise it will trigger to early). Is it possible to change the PIR parameter setting using LUA in a scene? edit: same question for 'GPS location frequency refresh'. When I am close to home I want to update it more often to be more accurate. If I'm far away, it can update less frequent, to save battery on my phone. Thx!
  12. I am trying to figure out how to shutdown my mac when i enable ssh port 22 by means of using lua code? How to start with this?
  13. Hi, I`m novice in Fibaro and LUA I have some TCP device in my network transmits a txt data to custom TCP port on HC2 if some event happens (e.g. alarm) How I can always listen that TCP port on HC2 via LUA and start to a custom action in case the txt data appear on the port?
  14. Hi, When editing a scene in lua the screen is very small. So I got this script to add a fullscreen button to make it easier to read en edit my lua, you paste the code in my Developer Console and hit enter. But of course after a refresh the button is gone. var sheet = document.styleSheets[0]; sheet.insertRule(".CodeMirror-fullscreen { position: fixed !important; top: 31px; left: 0; right: 0; bottom: 0; height: auto !important; z-index: 9; }", 1); CodeMirror.defineOption("fullScreen", false, function (cm, val, old) { if (old == CodeMirror.Init) old = false; if (!old == !val) return; if (val) setFullscreen(cm); else setNormal(cm); }); function setFullscreen(cm) { var wrap = cm.getWrapperElement(); cm.state.fullScreenRestore = { scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset, width: wrap.style.width, height: wrap.style.height }; wrap.style.width = ""; wrap.style.height = "auto"; wrap.className += " CodeMirror-fullscreen"; document.documentElement.style.overflow = "hidden"; cm.refresh(); } function setNormal(cm) { var wrap = cm.getWrapperElement(); wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, ""); document.documentElement.style.overflow = ""; var info = cm.state.fullScreenRestore; wrap.style.width = info.width; wrap.style.height = info.height; window.scrollTo(info.scrollLeft, info.scrollTop); cm.refresh(); } jQuery('body').append(jQuery('<div/>', { html: "Fullscreen", "class": "Button1_1", "style": " position: absolute; right: 10px; bottom: 10px; z-index: 10;", click: function () { editor.setOption("fullScreen", !editor.getOption("fullScreen")); } })) Can you add the fullscreen add-on from CodeMirror to the editor (https://codemirror.net/doc/manual.html#addon_fullscreen)? I needed to add a button in stead of using the F11 because it wasn't working on my MacBook. Kind regards, Giedo
  15. Hi, I'm trying to access from Virtual Device web page which requires authentication. Unfortunately "setBasicAuthentication" does not work here. Can you please advise how to authenticate the access. Server IP: '138.91.51.153'
  16. Hi, I currently use the script (Scene) below to turn off all lights when going to sleep. The problem is sometimes my adult children are still awake upstairs. How would I modify scene to turn off only downstairs lights? HC2 - Running latest version I thought of using the description field in devices and evaluating but can't work out the code. Help! --[[ %% properties %% events %% globals --]] local ids = fibaro:getDevicesId( { interfaces = { "light", }, properties = { dead = false, }, enabled = true, visible = true, -- optional --userDescription ~= "", -- attempt to evaluate if user description in device is not nil. } ); -- loop through light ids for i, id in ipairs(ids) do fibaro:debug("Turning off " .. fibaro:getName(id)); -- turn light off fibaro:call(id, "turnOff"); end Thanks Jason
  17. Guys, Problem, I have code below, however, change the value of Global variable "regenover" does not trigger the scene. I don't understand why not, someone able to help me out here ? --[[ %% globals regenover -]] local trigger = fibaro:getSourceTrigger() local regentijd = fibaro:getGlobalValue("regenover") if regentijd == "0" then fibaro:call(475, "turnOn") fibaro:call(782, "pressButton", "5"); elseif regentijd == "5" then fibaro:call(475, "turnOff") fibaro:call(782, "pressButton", "4"); elseif regentijd == "15" then fibaro:call(475, "turnOn") fibaro:call(782, "pressButton", "3"); elseif regentijd == "30" then fibaro:call(475, "turnOff") fibaro:call(782, "pressButton", "2"); end
  18. Hi All Following on from posts elsewhere about my issue I am convinced the problem lies with the block/lua conversion. However as a newbie I do not know enough to decipher the flow of the code. Primarily I need to understand how this scene is triggered when %%autostart is not used. I get that a manual start will set things going by the first 4 lines but how does the scene trigger otherwise? If someone could add some comments to the offending code below for me it would be most useful! --[[ %% properties 172 value %% weather %% events %% globals --]] local startSource = fibaro:getSourceTrigger(); if(startSource["type"] == "other") then fibaro:call(64, "turnOff"); fibaro:call(66, "turnOff"); else if (( tonumber(fibaro:getValue(172, "value")) == 0 )) then setTimeout(function() local delayedCheck0 = false; local tempDeviceState0, deviceLastModification0 = fibaro:get(172, "value"); if (( tonumber(fibaro:getValue(172, "value")) == 0 ) and (os.time() - deviceLastModification0) >= 200) then delayedCheck0 = true; end local startSource = fibaro:getSourceTrigger(); if ( ( delayedCheck0 == true ) or startSource["type"] == "other" ) then fibaro:call(64, "turnOff"); fibaro:call(66, "turnOff"); end end, 200000) end end
  19. Hello,every one! How to control air conditioning with Lua, I want to control the temperature in the scene, the mode of those.
  20. Hi, I had the requirement for a very simple scheduler. The code below is a stripped down version of @Sankotronic Main Scene code and just contains the Scene Scheduler. Thanks to @Sankotronic for his permission to post this. -- SIMPLE SCHEDULER. -- STRIPPED DOWN VERSION OF 'MAIN SCENE' CODE BY SANKOTRONIC --[[ %% autostart %% properties %% globals --]] if (fibaro:countScenes() > 1) then fibaro:abort(); end local jT = json.decode(fibaro:getGlobalValue("HomeTable")); -- comment out if you don't use a hometable local currenttime = os.date('*t'); local currentwday = currenttime['wday']; local TimeCurrent = os.date("%H:%M", os.time()); -- SCHEDULED SCENES SETUP -- (seperate multiple entries by comma) local runSceneSchedName = {"Test Scene 1", "Test Scene 2"}; -- Add scene names local runSceneSchedID = {641, jT.scene.Wakeup}; -- add scene ID's or references local runSceneSchedHour = {{"21:47"}, {"07:30"}}; -- Add times to run the scenes local runSceneSchedWeek = {{1, 1, 1, 1, 1, 1, 1}, {1, 1, 1, 1, 1, 1, 1}}; -- specify what day to run the scenes, Sunday is first day in array function doSceneSched() if #runSceneSchedID > 0 then for i = 1, #runSceneSchedID do if runSceneSchedWeek[i][currentwday] == 1 then for t = 1, #runSceneSchedHour[i] do if runSceneSchedHour[i][t] == TimeCurrent then fibaro:startScene(runSceneSchedID[i]); end end end end end end -- MAIN LOOP while true do currenttime = os.date('*t'); currentwday = currenttime['wday']; TimeCurrent = os.date("%H:%M", os.time()); doSceneSched(); fibaro:sleep(59700); end The full Main Scene code can be found at https://forum.fibaro.com/index.php?/topic/23510-scene-main-scene-for-time-based-events-control-v-125/ I thought this many be useful for some new users starting out or those like me that need a simple yet well written scheduler and may even be a stepping stone for some to the full Main Scene. -f
  21. This is feature request with low priority. So i will post it only on forum Better function of clipboarding from debug windows from VD debug window and LUA scene debug window. How it is now works: Succesfull clipboard: Hold left mouse button to select some debug lines and then ctrl+C for copy, while left mouse button is held down. Unsuccesfull clipboard: Hold left mouse button to select some debug lines, release mouse button and then ctrl+C for copy, while left mouse button is holded. What is requested: Hold left mouse button to select some debug lines, release mouse button and then ctrl+C for copy, while left mouse button is holded.
  22. Hello, I like to start a scene at every keypress on my Zipato Mini Keypad with RFiD Example: Zipato Away + PIN >>> Start scene Arm Zipato Home + TAG >>> Start scene DisArm Zipato Away + TAG >>> Start scene Arm Zipato Home + PIN >>> Start scene DisArm This works fine, no problem so far but if i'm also using my smartphone it doesn't work 1) Yesterday Alarm Disarmed by Zipato-Home-key + PIN 2) Today Alarm Armed by Smartphone 3) Today i try to disarm by Zipato-Home-key + TAG >>> NO TRIGGER Fibaro HC2 doesn't start a scene at step-3 because 'value' was not changed, for the system i pushed the home-key again (step 1 and 3) How do i trigger a scene with FIBARO LUA every time a key was pushed? ----------------------- Every key-press is send to Fibaro HC2 as it shows in the status screen [23:11:56] ID 299: locked by user 2 [23:24:50] ID 299: unlocked by user 2 [23:24:58] ID 299: locked by user 2 [23:25:25] ID 299: locked by user 2 [23:25:43] ID 299: locked by user 2 [23:25:54] ID 299: unlocked by user 2 [23:27:46] ID 299: locked by user 2 [23:27:52] ID 299: locked by user 3 [23:27:57] ID 299: unlocked by user 2 [23:31:03] ID 299: locked by user 2 [23:31:13] ID 299: unlocked by user 2 [23:47:04] ID 299: locked by user 1 [23:47:11] ID 299: unlocked by user 1 ----------------------- SCENE HEADER: --[[ %% properties 299 value %% events %% globals --]] Can somebody help?
  23. Hello I have a HC2 v4.130. I wanted to try to create a new virtual device with a simple lua script. However the script always fails with '[ERROR] 15:47:28: line 183: Assertion failed'. The script currently only consists of the following lines: if (fibaro:countScenes() > 1) then fibaro:abort(); end fibaro:debug("run complete") If I remove the 'fibaro:countScenes' command, the script is working. Is it possible, that virtual devices in v4.130 do not understand the fibaro:countScenes() command? What can I do to fix it or to work around this issue? Thanks.
  24. I have some device connected to z-wave plugs that can measure the energy consumption (devolo (Metering Plug MT:2646) and aeon labs (aeotec ZW075 v2) plugs are used). Now I would like every month a report how many kWh each of the plugs counted so far. Best would be to get that report by email. Is something like this possible in the HC2 eg with LUA? Can anybody help me to get started: - how to get the combined kWh from the devices - how to send an email - how to run the script only once per month thanks
  25. Hi, I am trying to connect to a secure web server, with a self-signed SSL certificate, using the net.HTTPClient() library in a scene. When I connect to the web server using my web browser, I get a warning telling me that the certificate is not certified by a valid authority, as you may have already seen on such certificate. In my web browser, I just click on the button to continue anyway. Firefox even allows me to add the certificate to the list of approved certificates. Problem solved But on HC2, I can't figure how to bypass the warning Here is the LUA code i use : local URL = "https://subdomain.domain.com/path" local httpClient = net.HTTPClient() httpClient:request(URL, { success = function(response) if response.status == 200 then -- Code to execute if successfull else fibaro:debug("Error : status=" .. tostring(response.status)) end end, error = function(err) fibaro:debug('httpClient:request() : Error : ' .. err) end, options = { method = 'GET', checkCertificate = false, } }) As you can see,I tried to use the "checkCertificate = false" option, but I doesn't seem to have any effect. I always get the following message : "sslv3 alert handshake failure" [DEBUG] 21:05:41: httpClient:request() : Error : sslv3 alert handshake failure The checkCertificate option seems to exist, as I found it as a string in the compiled binaries into the HC2. I tried both true and false boolean values, which seems to be accepted by the LUA interpreter, but I doesn't affect result as I would normally expect; If I try another value, such as a number or a string, I get a LUA Cast error and the script immediately ends. This is a proof that the checkCertificate parameter is used, but apparently with no effect. Can anyone confirm this strange behavior ? To Fibaro developers, can you confirm this parameter is correctly implemented ?
×
×
  • Create New...