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'.
-
Send info to a Google spreadsheet from Fibaro Lua
xirilius posted a question in Scenes and Interface
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 - ......- 2 replies
-
- spreadsheet
-
(and 2 more)
Tagged with:
-
Hello Forum, Relatively new to the HC2 I am struggling a bit with getting my head around all the undocumented functions and features in the HC2. Would anyone know more about the ones I am mentioning below, which are nowhere mentioned in Fibaro's documentation. The "Net" library Net.FHttp function Has a method called GET which requires some parameters. Which ones? How about POST, PUT and DELETE methods? Do they exist and if so which parameters do they take? Net.FTcpSocket function I came across a reference to this function in a post on this forum but I don't know how it works. The "api" library api.get, api.put, api.post functions Takes a local path as parameter so I am guessing this is a special implementation of the Net.FHttp function so one does not have to use the full URL for get/post/put etc. api.get("/icons") for instance gives all icons according to Fibaro's REST-interface definition Is there an api.delete function as well? Googling the above does not give any indication that these libraries are generic LUA libraries so my conclusion is that they must be Fibaro-specific. But I could be wrong of course. Storing tables in global variables I came across this VD (by Sankotronic) on the forum that helps you browse the icon library: Looking through the code I found this very interesting concept of storing an entire data structure in a global variable. Check out the main loop in the VD. Very clever indeed! The question then, which are the principles behind this very convenient way to handle variables? I mean, the standard functionality can only handle numbers and predefined values, not strings or collections of data. Thanks! Per
-
HC2 & OpenZwave Class: MCO Home MH7 Time Synchronisation
Tom1890 posted a question in Urządzenia Firm Trzecich
hallo, Ich habe mehrere MCO Home MH7 Thermostate in meiner Wohnung installiert. Nach dem Neustart des HC2 wird die Uhr der Thermostate zurückgesetzt. Die meiste Zeit ist die Uhr auf UTC-Zeit statt CET eingestellt. Nachdem sie den Support von MCO Home kontaktiert und gefragt haben, wie sie die Zeit mit LUA zurücksetzen könnten, sagten sie mir, dass sie OpenZWave-konform sind. Ich sollte innerhalb der Klasse "COMMAND_CLASS_TIME_PARAMETERS" den Befehl "TIME_PARAMETERS_SET" verwenden. Weiß jemand, wie ich ZWave-Klassen ( http://www.openzwave.com/dev/classOpenZWave_1_1TimeParameters.html ) in einem LUA-Szenario aufrufen kann ? Danke & Mit freundlichen Grüßen thomas- 2 replies
-
- synchronisation
- time
- (and 4 more)
-
Hi, I think there is an issue with PIN protected scenes that are triggered from LUA configured popup or interactive push notifications. Scenes that should be PIN protected run straightforward when triggered from "YES" button on such notifications. Here are tutorials for setting such notifications up - courtesy of @Sankotronic: - popup notifications: - interactive push: Best regards, Andrzej
-
I have a scene that is suppposed to check a variable called "Snow" at Monday through Friday at 5 am and 3 pm and weekends at 7 pm and 3 pm. If Snow = "Yes", a scene is activated, turning on my outdoors heating mats for 2 hours (and at the same time resetting Snow = "No"). My thinking is to limit the use of expensive snow melting electricity to max 2 + 2 = 4 hours / 24 hours The problem with the code below is that the scene triggers with variable Snow = "Yes" also outside the stated hours. What is it I am not getting right here ? I thought the AND operator had hierarchial priority over OR and that the code below would turn on the heater if the variable Snow = "Yes" AND the time is 5 am or 3 pm on weekdays or 7 am and 3 pm in weekends. But it seem to trigger whenever the variable Snow = "Yes", also outside these hours. Help will be highly appreciated! (Scene 51 is the scene actually turning on the heating mats for two hours): Best regards Jo --[[ %% autostart %% properties %% weather %% events %% globals Snow --]] local sourceTrigger = fibaro:getSourceTrigger(); function tempFunc() local currentDate = os.date("*t"); local startSource = fibaro:getSourceTrigger(); if ( ( ((currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "05:00") ) and ( fibaro:getGlobalValue("Snow") == "Yes" ) or ( ((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) == "15:00") ) and ( fibaro:getGlobalValue("Snow") == "Yes" ) or ( ((currentDate.wday == 1 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "07:00") ) and ( fibaro:getGlobalValue("Snow") == "Yes" ) ) then fibaro:setGlobal("Snow", "No"); fibaro:startScene(51); end
-
Hi, I hope this is an acceptable post as I have spent a long time looking for the answer before posting. I want to create scenes using Lua, and have created a very simple one (swithcing on three lights) after watching a Youtube video. However, I feel I need a primer to learn the basics and set up my system with the necessary "starter variables" etc. I have looked in Fibaro knowledge base, Fibaro manuals and elsewhere on the internet, but not really found what I am looking for. Can anyone point me to a good resource? Thanks in advance.
-
Going crazy - need help with LUA : 1 Lamp, 2 or more wall switches
D4RK1 posted a question in Scenes and Interface
Hi, hope someone can help me. I´m new to LUA and programming in general and I am trying to get a simple (so I thought) scene to work. What I want to do: I have a lamp in my dining room which is connected to a fibaro rgbw controller. I have two (or maybe three) wall switches connected to fibaro dimmer 2 and fibaro double switch 2. The lamp and switches are working as they should. If I program them indepently, they control the lamp. Now I want to have them control the lamp together. So if either of the switches is set to "On", the lamp should switch On as well and vice versa. I have been fiddling around with several ideas but nothing works as intended. Right now I am trying 2 switches and 1 lamp, I might want to add another switch later, but that is not important now. Currently I am thinking that I need to change the value of the "other" switch to match the switch I used to control the lamp. Meaning I Turn Switch1 "On" and Lamp and Switch 2 are set to "On". The problem is, the state change of Switch 2 triggers the scene again. At least I think that is the problem. I cannot believe that I am the first or only one that wants to control 1 lamp with several switches. If someone has a working script for this, please share =) Regards, Jens -
How do i get the current set point of a heating panel zone via a lua scene? i tryed this i get a error --[[ %% properties %% events %% globals --]] local PanelID = 10 local panel, status = api.get("http://192.168.1.34:80/api/panels/heating/10" ..PanelID) local currentTemp = panel.properties.currentTemperature fibaro:debug(currentTemp)
-
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 ?
- 5 replies
-
- lua
- boolean logic
-
(and 2 more)
Tagged with:
-
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!
-
[Help Needed] Lua code to get the device which triggered alarm
Lambik posted a question in Scenes and Interface
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! -
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
- 2 replies
-
- hc-2
- virtual device
-
(and 1 more)
Tagged with:
-
Merry Christmas Hi, sometimes I get this Error message in a Lua scene: >>Cannot query interpreter state<< What does it mean??? I can't see any impact from it. Thanks for any input.
-
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!!!
-
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
-
Dear colleagues, does anybody know how to create scene in LUA for switching a heating panel to the manual mode?
- 5 replies
-
- heating panel
- manual mode
-
(and 1 more)
Tagged with:
-
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?
-
List of device actions that requires an additional argument?
Guest posted a question in Scenes and Interface
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 -
[SOLVED]Too many instances in a LUA script for a RF keypad. [solved]
RobVeenis posted a question in Home Center 2
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!- 9 replies
-
- too many instances
- rf keypad
-
(and 1 more)
Tagged with:
-
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?
-
Hi. I'm an experienced programmer, but a novice in LUA. 1. I have some qubino smart meters, and would like (of course) to read all the parameters they can provide. It seems to me that every single parameter in them get an ID in HC2. When I want one of the values, i use fibaro:getValue(63,'value'); But: For some of the parameters there are no ID's! So how can I get their values? Examples of missing parameters are 143: Reactive power total and 144: Power factor total How can I get to those? 2. Is there a way to get parameters based on the device parameter numbers? I'd like to use some function v=fibaro:getParameter(main id,parameter number); Is this possible? 3. Where can I find a list of legal parameter values to the getValue call? Helgemor
-
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
-
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
-
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