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'.
-
Hello, I have an application where if I manually turn on a light, I need to know that the light was manually turned on and not automatically by some sensor. But I stuck at setting and reading the value of the global variable. The value printed is always Nil. Why? This is the only code in the LUA scene. local value = tonumber(hub.getGlobalVariable("GarageLightBackForced")) hub.setGlobalVariable("GarageLightBackForced", tostring(2)) hub.setTimeout(900000,function() hub.setGlobalVariable("GarageLightBackForced", tostring(0)) end) print(tonumber(hub.getGlobalVariable("GarageLightBackForced"))) -- print to debug only Help
-
I have been trying to create the following scene in LUA: When i double click the light switch (Fibaro Switch 2), i want to turn all the room lights on. I have set the switch's parameters 28 and 29 to enable 2x click. I have also set the parameter 20 to the correct switch type. This is my object IDs: This is my LUA scene code (I have used this code as a template, since i don't know much about lua https://forum.fibaro.com/topic/23423-switch-2-trigger-scene/😞 --[[ %% properties %% events 109.0 CentralSceneEvent %% globals --]] local pressSource = fibaro:getSourceTrigger()["event"]["data"] --fibaro:debug(json.encode(pressSource)) if (tostring(pressSource["keyAttribute"]) == "Pressed2") then fibaro:debug('Pressed 2 times') if fibaro:getGlobalValue("Home") ~= "1" then fibaro:setGlobal("Home", "1") fibaro:debug(" Global Home set to "..fibaro:getGlobalValue("Home")) fibaro:startScene(68) else fibaro:setGlobal("Home", "0") fibaro:debug(" Global Home set to "..fibaro:getGlobalValue("Home")) fibaro:startScene(69) end end So the idea would be: if key is pressed 2x, the variable "Home" gets 1 (and trigger sceneID 68 - turn all on) or 0 (and trigger sceneID 69 - turn all off) The issue is that i don't know which "CentralSceneEvent" ID to use, i tried 109.0.1 (remote controller) but it didn't work. How does these IDs work exactly for this type of event call? What should i point the id to? Another thing i would like to know: Here i use a single ID that would call to both S1 and S2 of one switch. Can i insert more CentralSceneEvent IDs into this code, so that more switches can trigger the same scene, or i should copy this scene and create a new one for each switch? EDIT: So i figured i was not using the correct ID's to trigger the scene. The 109.0 is actually 110, which made the scene work. Now i just have to figure if i can use more than one ID in the same scene, or if I have to duplicate the scene and switch the ID to the other switch that needs to trigger too. Does anyone know that?
-
Hi, we use 6 MCO MH7 devices in our house and all have the same behavior. I have scenes with the Device MCO MH7 Heating Control. They worked propely. I am switching the temperature based on a heating plan for our water florr heating. Since the inclusion of the "Engery safing heating" state I got the problem, that the temperature isn´t set well to the new values. fibaro:call(420, "setSetpointMode", 11) fibaro:call(420, "setThermostatSetpoint", 11, "21"); fibaro:call(420, "setSetpointMode", 1) fibaro:call(420, "setThermostatSetpoint", 1, "21"); to be safe I also send it to both "setpointMode", but sometimes the device doesn´t catch the new value. Is some one here who has the same issue or know how to solve it?
-
- scene
- homecenter
-
(and 4 more)
Tagged with:
-
Hi Brains, This was working fine with my HC2. I've just moved to HC3 and I'm perplexed by the following behaviour: I have a Fibaro Dimmer with an S2 button and I have parameter 28 active and everything else is default. And this is happening with 5 separate dimmers. So when I double click the S2 btn for the first time it prints out DoubleClick and works fine. However the second time I double click it though it doesn't do anything. I try it again and nothing. I then single click the S2 btn and it prints out Click. I then double click and it works and prints out DoubleClick. However I try double clicking again and nothing. Same thing happens for single clicking the S2; first time it works and prints Click. Try it again and nothing happens. Try it again still nothing. Its not until I double click and it prints DoubleClick and then can single click and it prints Click. Any ideas what I've done wrong? { conditions = { { id = 23, isTrigger = true, operator = "anyValue", property = "sceneActivation", type = "device" } }, operator = "all" } local Debugger = 'True' local sa = sourceTrigger if sa.value == 16 then if Debugger == 'True' then print('Click') end end if sa.value == 22 then if Debugger == 'True' then print('Hold') end end if sa.value == 23 then if Debugger == 'True' then print('Release') end end if sa.value == 24 then if Debugger == 'True' then print('DoubleClick') end end if sa.value == 25 then if Debugger == 'True' then print('TripleClick') end end if sa.value == 26 then if Debugger == 'True' then print('Click') end end
-
- s2
- dimmer switch
-
(and 2 more)
Tagged with:
-
Hi everyone, So I have a Skaro automation bridge which connects my iZone HVAC system to my HC3. On the quickapp is a label representing the current temperature in the zone: I cannot seem to reference the lblTemperature value in LUA. I am actually trying to get the actual temperature into a global variable within a scene but cannot work out the syntax. I downloaded the device file under advanced to see if I can see any other references to lblTemperature but cannot see how it gets the value from the device. I assume it is part of the API. So for the scene action I just have local MST = hub.getValue(99, "lblTemperature") print(MST) where the QA device is 99 and the debug screen displays: [07.10.2023] [15:08:11] [DEBUG] [SCENE74]: nil I'd really appreciate any ideas you may have. Thanks. Anth
-
Hi there, recently updated to a HC3 and would like to add 2 Deye inverter to the energy panel. I did my research, but no idea how to implent it. Inverters are accesible via http://username.password@IP/status.html. Any idea and help would be great! Regards Francisco
-
Witam, szukam odpowiedzi na uważam dość szczegółowe pytanie dotyczące QuickApp. Otóż postawiłem sobie cel by z pomocą QuickApp "Termostat auto" zrobić sterowanie prędkością wentylatora od klimatyzacji. W termostacie MCO Home MH8-FC spotkałem się z czymś takim że ma on taką wbudowaną opcję w interface służącą do tego, dodatkowo ma też sekcję pokazującą w jaki jest stan jego pracy, wygląda to tak: Zależy mi na tym żeby stworzyć QuickApp, który też będzie miał te dwie sekcje, chodzi o to żeby nie tworzyć tego ręcznie za pomocą kontrolek i etykiet.
-
Query JLR InControl SoC of Electric Vehicle
Corceiro posted a question in Other Devices / Third-party devices
Does anyone already tried to access JLR InControl API with LUA code to get the State of Charge (SoC) of their vehicles (Jaguar I-Pace or some Land Rover PHEV cars like the Evoque P300e)? I have some lines of code working on Google Apps that can query that value and put it on a Google sheet cell. Is it possible to convert it to Z-Wave LUA (Home Center 3)? It could be great to get the SoC and use that value in some scenes associated to the different electric costs tariffs. -
Hi Fibaro/Community, Before buying fibaro and 90+ devices to set up the house, I did some basic programming on the HC2. I liked the ability of making a small function library and using my functions in scenes and triggers. I am not a great programmer but the great help of the community and code snippets available make a central function library VERY useful to a novice like me and makes it easy to write a function once and then use it successfully later. However I ended up buying HC3 and here EVERYTHING is different. As many have written. For the great programmers this seems to be no problem, you guys are deep into QuickApps and OO classes and the loss of the HomeTable is not a problem for you, and the amazing EventRunner class in HC2 seems to have found a home in Quickapps - BUT - this is pretty hard for the novice like me to follow. It is like Fibaro has decided to provide a super complex API but no path to learn in steps for the novice. Like playing Donkey Kong without ramps up. Fibaro if you are listening : What is the way for a novice to make a function library with simple small functions to reuse in scenes? Like a small function to turn on a given ID of a light, then turn it off 60 seconds later. Trivial I know, but why copy this 100 times in each scene when a function would do? Fibaro, also, how to create a table of all the IDs of my motion sensors and a column with light IDs to turn on, and the time delay until turn off? The hometable concept in HC2 could have done that. But in HC3? I know it is super advanced somewhere up there but for basic programmers like me who have googled and read the forums and only found the super stuff like Quickapps, what do we do? It seems to me there are only 20 people in the world who understand HC3. Like Quantum Mechanics. You need please to help the people below that..
-
Is it possible to create a Lua code when a relay or switch changes state (e.g. from on to off). I often get multiple messages instead of one. For example, if I choose to receive a notification when my thermostat's relay goes from off to on, the notification works, but a few minutes later I get that notification again and again... Thanks
- 1 reply
-
- device
- change state
-
(and 1 more)
Tagged with:
-
This is a Quickapp script for HC3. I am trying to get this to work in a VD on HC2. Is it possible, or do I have to do it together with a scene to make it work? Can anyone help? function QuickApp:onInit() self:updateProperty("unit", "kr/kWh") self.refresh = 60 -- in seconds local function loop() self:webrequest(); setTimeout(loop,self.refresh * 1000) end if self.username ~= "changeme" then loop() end end function QuickApp:webrequest() local tid = os.date("%R") local minutt = os.date("%M") --OPPDATERER STRØMPRIS OG SNITT HVER TIME if (minutt == "00") then self:OppdaterPris(); self:OppdaterSnitt(); end end function QuickApp:OppdaterPris() --Opprette lokale variable local GammelStrompris = fibaro.get(126,"value") local NyStrompris --Definerer http local http = net.HTTPClient(); --Definerer strengen Payload til å være kommando til tibber local payload = '{"query": "{viewer {homes {currentSubscription{priceInfo{current{total}}}}}}", "variables": null, "operationName": null}'; --API.POST til Tibber-- http : request('https://api.tibber.com/v1-beta/gql', { options = { method = "POST", headers = { ['Authorization'] = '.........', --Min Tibber ID her. ['Content-Type'] = 'application/json' }, data = payload -- Query. }, success = function(response) --fibaro.debug (response.data) --Verifiser at en har fått response.data. Dette er data som en har fått fra Tibber local data = json.decode(response.data); --fjernet local under??? NyStrompris = json.encode(data.data.viewer.homes[1].currentSubscription.priceInfo.current.total); self:updateProperty("value", tonumber(NyStrompris)) --print("OK") end, error = function(err) fibaro.debug ("Error:" .. err) end }); end function QuickApp:OppdaterSnitt() --Definerer http local http = net.HTTPClient(); --Definerer strengen average til å være kommando til tibber local average = '{"query": "{viewer {homes {currentSubscription{priceRating{daily{entries{total}}}}}}}", "variables": null, "operationName": null}'; --API.POST Til Tibber http : request ('https://api.tibber.com/v1-beta/gql', { options = { method = "POST", headers = { ['Authorization'] = '...............', --Min Tibber ID her. ['Content-Type'] = 'application/json' }, data = average -- Query }, success = function(response) --fibaro.debug(response.data) --Verifiser at en har fått response.data. Dette er data som en har fått fra Tibber local data = json.decode(response.data); local Nypris = tostring(json.encode(data.data.viewer.homes[1].currentSubscription.priceRating.daily.entries[31].total)); self:updateProperty("log", tostring(Nypris)) end, } ) end
-
-
Hello, As a beginner I'm trying to understand lua a bit. I have a small lua code that gives the temperature of the room thermostat. Lines 10 and 20 work perfectly, (the mail is sent), but lines 30 and 40 don't work. (load):4: attempt to concatenate a nil value (local 'heatingThermostatSetpoint') The "heatingThermostatSetpoint" is a virtual thermostat, linked to the room thermostat. Does anyone know what to do. Can someone also tell me how I can get different results in 1 email. Thanks.
- 3 replies
-
- thermostats heating
- lua
-
(and 1 more)
Tagged with:
-
I am writing a scene which needs to set the setpoint temperature of my Z-TRM2 thermostats using a LUA command in HC2. I plan to address each thermostat individually, not through heating panels. The current value is succesfully retrieved by this command: fibaro:getValue(id, "value") where id is the id for the setpoint sub-device of the thermostat. This works as expected. However, when I try to change the setpoint through this command: fibaro:call(id, "setValue", "18") nothing happens, as shown by a subsequent getValue call. There is no error message, but the setpoint remains unchanged. I have tried to use the numeral 18 in stead of a string, and I have also tried with a variable name.What am I doing wrong in my fibaro:call command? The syntax is taken from the LUA API documentation, where this example is given: -- 'setValue' action call with one additional parameter fibaro:call(12, 'setValue', '23'); Is the required command for the Z-TRM2 module different?
-
HC3L - Fibaro Heat send notification by temperature change
tobiassschulz posted a question in Scenes and Interface
Hi, I would like to receive a notification, when the temperature on the fibaro heat controller is manually changed. I tried to write a lua scene, but I don´t know how to use change of "Setpoint" as trigger. Thanks for your help -
Hi, I'm new to LUA but I am trying to read the current value of R and assign it to B. I basically have 2 white strips and 2 sets of downlights, assigned to the RGBW channels. I want the 2 sets of strips to copy each other and the 2 sets of downlights to copy each other, so if I dim one strip, it mimicks on the other strip and if I dim one set of downlights it mimicks on the other set of downlights. So I want to read the current value of R and assign it to B and read the current state of G and assign it to W. Thanks in advance!
-
Czy ktoś może podpowiedzieć jak stworzyć scenę w której z określonym interwałem czasowym centrala wyśle powiadomienie push z informacją o aktualnej wartości czujnika? Chciałbym aby klient raz na dzień dostawał info jaka jest wilgotność powietrza, ponieważ jest to ważne dla odpowiedniego utrzymania jego drewnianej podłogi. ____________ Can anyone suggest how to create a scene in which, with a specific time interval, HC3 will send a push notification with information about the current sensor value? I would like to receive information about the air humidity once a day, because it is important for the proper maintenance of client wooden floor.
-
Hi I'd like to open/close the danalockv3 id541 using two triggers. Holding the light switch (the danalock status changes each time the key id553 is held down) or the alarm output (the ldanalock status changes depending on the alarmoutput id430 status on/off on=unsecure off=secured). In addition, the alarm output state should be synchronized with the lock state, because I can open the lock manually for example. How to modify the lua code below to add a second trigger to it (alarm out) and synchronize lock state? { conditions = { { id = 553, isTrigger = true, operator = "==", property = "centralSceneEvent", type = "device", value = { keyAttribute = "HeldDown", keyId = 1 } }, { id = 430, isTrigger = true, operator = "!=", property = "state", type = "device", value = {} } }, operator = "any" } local deviceValue1 = fibaro.get(541, "value") if deviceValue1 == true then fibaro.call(541, 'unsecure') else fibaro.call(541, 'secure') end
-
I am very conversant with the HC2 stuff. For the HC3, the last time I looked at this a year ago, the offerings were rather disappointing with a steep learning curve. Could some one recommend A decent example of a lua scene. I am fine with the language change - I have just grepped and done global modifications on my 30 odd lua scenes. I am looking for a better explanation of the new trigger mechanism. A decent example of the new VD and any gotchas. Before I could just save the lua as a text file on pc with versioning. How are people saving the new scenes, as they come in two parts ?
-
I am trying to push a certain button from a different device, if the door is closed, but I cant locate how to let FIBARO know that the door is closed. How can I do that in scenes? Thanks in advance.
- 5 replies
-
- door sensor
- lua
-
(and 1 more)
Tagged with:
-
I am trying to start a boiler and a heater from an URL that has a lot of prices and timestamps. I am using Home Center 2. I have no idea where to start from, I understand I need VD (Virtual Devices) and Scenes, but anything I have tried hasn't worked sadly. How can I start a boiler and a heater during the lowest prices with JSON timestamp values from an URL? If required, I can post the URL here. Can anyone help me?
-
Hello. I have written a code in LUA 5.4 which gives me a list of prices and timestamps through a URL, and on FIBARO HC2 it wont work. I understand that FIBARO HC2 uses Lua 5.1 or something like that. I am trying to start a boiler and a heater using HC2, but I have no idea how to start with that. How can I start the boiler and a heater at the time when prices are low on HC2 using a website URL? If required, I will provide more information in the comments. Thanks in advance.
- 1 reply
-
- automation
- api get
- (and 4 more)
-
Remove percentage from slider or make it whatever I want
carlosdr02 posted a question in FIBARO Mobile
Is it possible to change the range of a slider, I mean, instead of going from 0% to 100%, can I make it go from 15ºC to 30ºC somehow, if not, can I remove the percentage tag of the slider completely? Thx -
Quick question: How can I update the value of a slider? I've tried self:updateProperty, self:updateView, fibaro:call, etc, and none of them seem to work.
-
How can I add the custom controls that appear on templates
carlosdr02 posted a question in FIBARO Mobile
There is supposed to be only three types of controls: buttons, sliders and labels, but if I create a Quick App with a template (thermostat auto for instance), I has other controls, like combo boxes. How can I add those custom controls or create them myself. And why can I not delete the controls of the templates, I mean, if I use a template, I can only delete the controls that I add on top of the default ones, in fact, those templates controls don't even show up in the preview window. whut ?¿?¿