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 everyone, As many before on this forum I'm working on my heating system and want to convert my current single room heating plan into to a multi zone heating plan. I want to integrate my boiler into my heating plan but want to create some safety interlock that I won't fire up the boiler if all the thermostats are closed. I think this is a very important feature and often overlooked as the behavior of a thermostat is to close more and more when the thermostat is reaching it's set-point to prevent overshoot. So therefore I need to know what to position is of the valve, based on that condition i went for the TRV's of eurotronic as it stated in the manual that it is able to report it's current valve position. And it looked like everything would work correct with the fibaro template as I was able to set parameter 6 and enable the valve postion reporting. I think everything is configured correctly but i have a bit of strange behavior now in fibaro when I enable parameter 6. The setpoint value is getting overwritten with the valve position percentage: Setpoint displays: new setpoint in degree Celsius After few minutes same device is overwritten and setpoint value displays Open valve percentage (unit doesn't update and stays on degree Celsius): Enabled parameter 6. When i change setpoint and debug the info. I noticed the following behavior: Setpoint change -> Setpoint value displays setpoint -> after few minutes Setpoint value displays: valve position -> Setpoint value displays setpoint value again. Maybe I'm looking at the wrong values but here is the list of the available values: I wasn't able to locate the opening valve percentage value in this list to make a virtual device as work around.. Does someone have a solution for my problem? I would like to receive the actual setpoint and the open valve percentage on a different value/device.
- 21 replies
-
- eurotronic
- lua
-
(and 4 more)
Tagged with:
-
Hello Everyone, I am working on some projects that seeks help in finding the appropriate tutorials for lua programming. I want to learn lua right from the basics and take it step by step. Where can I get these tutorials?
-
Hello, I found a project who reverse engineered the Wi-Fi protocol from the Mertik controller connected to my fireplace. Yeay! ? With the following (simplified) NodeJS code I can send the standby command to my fireplace: var net = require('net'); const prefix = '0233303330333033303830' var msg = "3136303003"; var packet = Buffer.from(prefix + msg, 'hex'); var client = new net.Socket(); client.connect(2000, '192.168.1.1'); client.write(packet); I know how to open a socket in HC3 QA but I don't get how to convert the message to a RAW buffer. The JavaScript line does it with Buffer.from(prefix + msg, 'hex'); Does some LUA god know how to convert the message in QA LUA for the HC3?
-
Anybody knows a way to know what triggered the scene? For example I have a scene, that can be triggered by one of two switches. And in the Lua code I'd like to know which one of these two switches triggered the scene.
-
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 !!!
-
Does this Trigger autostart a lua scene ? Its supposed to be gateway start, which makes no sense { type = "se-start", property = "start", operator = "==", value = true, isTrigger = true }
-
The new HC3 LUA sytax for email fibaro.alert('email', users, "xxx") has no room for the subject. The subject is always "Message from FIBARO". Is there a way to change this?
-
Change a single parameter value using lua code scene
IanRow posted a question in Scenes and Interface
Hi - I would like to modify a device parameter configuration using a scene. In this example I have a set of security lights which have a timer to switch on for 60 seconds. sometimes we want to use them as normal lights and i'd like to be able to set the timer to 20 minutes so they dont keep turning on and off. Parameter number 1 desired value would change using lua code to 1200. thanks. -
Hello I'm new to making scenes in HC3, -just bear with me. Thought to start with some simple things like Trigger and Conditioning. Have a source I want to get a message if the temperature is above 9 degrees But the scene is running even though the temperature is below 9 degrees (see picture) Have tried to read on how to do. Feels like it's a simple thing I am missing I have also the same problem with freezer (not unexpected but i guess ) But i would like to have that on -18 in stead
-
I have used a LUA script which is triggered by pushing the switch 2 on a Fibaro switch. Depending on whether the key is pushed once, twice or held, I control another device (a light) according to set rules. How the key is pushed, is found by the variable pressSource = fibaro:getSourceTrigger().event.data. This solution has been used previously by several contributors on the forum. My current code looks like this (only first part shown): --[[ %% properties %% events 394 CentralSceneEvent %% globals --]] -- Uses first slave for "CentralSceneEvent" ID (not master, not switch itself). Here 394 local trigger = fibaro:getSourceTrigger() if (trigger.type == "other") then fibaro:debug("Scene started by clicking 'start' button") else local pressSource = fibaro:getSourceTrigger().event.data fibaro:debug("New: CentralSceneEvent received from key: " .. pressSource.keyId) if (pressSource.keyId == 2) then local ledId = "306" local ledValue = fibaro:getValue(ledId, "value") if pressSource.keyAttribute == "Pressed" then fibaro:debug("Pressed") if ledValue == "0" then fibaro:call(ledId, "turnOn") else fibaro:call(ledId, "turnOff") end elseif pressSource.keyAttribute == "Pressed2" then fibaro:debug("Pressed 2 times") fibaro:call(ledId, "setValue", "100") elseif pressSource.keyAttribute == "HeldDown" then -- etc. (complete code not shown) I now want to add a second trigger, i.e. another Fibaro switch being pushed. Depending on which switch is used, I want different lights to be adjusted. Below is my first edit (still incomplete). In line 5, the new trigger 494 is added. How do I know if the scene was triggered by 394 or 494? The answer is probably in fibaro:getSourceTrigger(), but I cannot find the complete specification for this function documented anywhere. Specifically: - How do I find whether 394 or 494 was the trigger? The syntax trigger.event.id in line 14 is my guest guess. What is correct? - Once I have the right triggerID, I can easily make the variable ledID dependent on triggerID, by having two related lists (arrays): {394, 494} for the triggers and {306, 406} for the corresponding LED lights. This needs to be implemented in line 18. Can anyone please provide a more complete specification for the data returned by fibaro:getSourceTrigger in HC2, and show me how I can use it to implement double triggers? Or are you all too busy converting to HC3? PS: I have simplified this to TWO triggers. In reality I want to have several more. But if I can do two, I can do any number. --[[ %% properties %% events 394 CentralSceneEvent 494 CentralSceneEvent -- <<--- NEW TRIGGER %% globals --]] -- Uses first slave for "CentralSceneEvent" ID (not master, not switch itself). Here 394 and 494 respectively. local trigger = fibaro:getSourceTrigger() if (trigger.type == "other") then fibaro:debug("Scene started by clicking 'start' button") else local triggerID = trigger.event.id -- <<--- WHAT IS CORRECT SYNTAX?? local pressSource = fibaro:getSourceTrigger().event.data fibaro:debug("New: CentralSceneEvent received from key: " .. pressSource.keyId) if (pressSource.keyId == 2) then local ledId = "306" -- <<<< NEEDS TO BE CHANGED TO CORRESPOND TO triggerID local ledValue = fibaro:getValue(ledId, "value") if pressSource.keyAttribute == "Pressed" then fibaro:debug("Pressed") if ledValue == "0" then fibaro:call(ledId, "turnOn") else fibaro:call(ledId, "turnOff") end elseif pressSource.keyAttribute == "Pressed2" then fibaro:debug("Pressed 2 times") fibaro:call(ledId, "setValue", "100") elseif pressSource.keyAttribute == "HeldDown" then fibaro:debug("HeldDown") -- etc. (complete code not shown)
-
How to synchronize the mode, temperature and wind speed of two HVAC
Gee posted a question in Scenes and Interface
How to synchronize the mode, temperature and wind speed of two HVAC I can't find a way in the associated page. Is there any way to synchronize with LUA scenes or other ways? Thank you -
fibaro.call can't sent a class object to another QuickDevice
NLWaard posted a question in Home Center 3
Locally I can place the current class (self) in a variable and call an Object in this class. This code is working (localy): function QuickApp:onInit() local sender = {value='Yes', class=self} sender.class:localPrintValue(sender.value) end function QuickApp:localPrintValue(value) if value == nil then value = 'No' end self:debug('Can I print this : '..value) end [15.09.2020] [13:22:42] [DEBUG] [QUICKAPP105]: Can I print this : Yes If I send this variable to another class using fibaro.call(id, 'action', variable) , the call disappears into the darkness. Calling the Object in the other class(QuickApp) results in calling the nil value? !!! This next code is (because of the class=self) not working: fibaro.call(qaID,"updateMyProperty", {value=newValue, class=self}) function QuickApp:updateMyProperty (sender) local value = 0 if type(sender) == 'table' then -- Call comes from elsewhere.. value = sender.value self:debug('Device updated from: '..tostring(sender.class.id)..'.'..tostring(sender.class.name)..' with value: '..tostring(value)) else value = sender self:debug('local call, with value: '..tostring(value)) end end This is a pity because I would like to indicate in the called class where the call was coming from. Now I solve this by sending a table with : sender = {id=self.id, name=self.name, value=newValue}. Do I do something wrong? or has Fibaro disabled the oop function for sending object classes? -
Hi, I have several problems to get my HUE lights working white my Fibaro HC2. I have made a scene for my bathroom just to turn on and off the light in combination white a motion sensor. This is working fine but the light is always changing back to the warm color after about 24 hours. So i like to set the color by a LUA command. I used the debug function for the settings (see below) --[[ %% properties %% events %% globals --]] fibaro:debug(fibaro:getValue(162, "ui.brightness.value")) fibaro:debug(fibaro:getValue(162, "ui.saturation.value")) fibaro:debug(fibaro:getValue(162, "ui.hue.value")) If i change the Brightness on the HUE app the value changed. But the saturation and HUE value doesn't change at all. Whats the problem? is it a error of the Hue bridge (square one) or anything else??? This Youtube example looks oke to me: All you input is welcome and of course i can provite more information if necessary. Thank you in advance. Michel
-
Hi Im Serching for a simple Lua Script that sends me a Message when the outdoor temperature is under the indoor temperature. My Outdoor temp Sensor is ID: 263 and indoor temp Sensor ID is 258. Can me anybody help Please? Thanks a Lot!
- 15 replies
-
- lua
- tempsensor
-
(and 4 more)
Tagged with:
-
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.
-
Hello I'm new at lua programming and trying to use a variable to change light on or off, from a second button. But i can't get the variable to work. What is wrong here. Declaration { conditions = { { id = 187, isTrigger = true, operator = "==", property = "state", type = "device", value = false } }, operator = "all" } Actions local Status_186 = fibaro.getValue(186, "value") if Status_186 == 'ON' then fibaro.call(186, 'turnOff') else fibaro.call(186, 'turnOn') end
-
Próbuję właśnie napisać scenę aktywowaną KeyFob, która w zależności od stanu żaluzji będzie kontynuowała poprzedni kierunek działania lub zatrzymywała żaluzję. Natrafiłem na pewne braki w dokumentacji, wiem tylko jak pobrać poziom zamknięcia rolet: fibaro.getValue(117, "value") Wiem też że za pomocą kilku warunków mogę napisać funkcję sprawdzającą czy ta wartość się nie zmienia. Szukałem jednak w internecie jakie inne własności urządzenia mogę pobrać za pomocą `getValue` niestety jednak nie znalazłem nic na ten temat. Czy ktoś może wie gdzie taka dokumentacja może się znajdować?
-
Hello, I am trying to build a Lua script that will tell Fibaro if I am working from home, working at home or off work. Here is what I have so far but I need some help to get the scene trigger when either I am at home or at work when all the conditions have been met at the specific times. Does anyone have a similar scene or suggestions? --[[ %% properties %% events %% globals --]] local currentDate = os.date("*t"); local time=os.date('*t'); local ct=os.date('*t'),os.date("%H:%M",os.time()) if (fibaro:countScenes() > 1) then fibaro:abort(); end if ((fibaro:getGlobalValue("AndyPresentstate") == "Home") and (currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) and ((ct>= "08:30") and (ct<"17:00")) ) then fibaro:setGlobal("Working", "At Home"); fibaro:debug("working at home"); elseif ((fibaro:getGlobalValue("AndyPresentstate") == "Home") and (currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) and ((ct>= "17:00") or (ct<"08:30"))) then fibaro:setGlobal("Working", "Off Work"); fibaro:debug("off work"); elseif (fibaro:getGlobalValue("AndyPresentstate") == "Away" and (currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) and ((ct>= "08:30") and (ct<"17:00")) ) then fibaro:setGlobal("Working", "At Work"); fibaro:debug("Working at Work"); end
-
Hi everybody, I seem to be stuck in my search how to implement a (large) mobile popup, triggered in a LUA scene in HC3. I found this example for HC2: https://manuals.fibaro.com/knowledge-base-browse/how-to-create-mobile-pop-up/ This is actually what I want to create, a large popup with buttons and actions connected to it. But the example (obviously) does not work in HC3. I am using the following code and the fibaro.homeCenter.notificationService.publish function with type set to MobilePopupNotification as described in https://manuals.fibaro.com/home-center-3-lua-scenes/ local function popupMessage(message) local request = { type = "MobilePopupNotification", priority = "warning", data = { title = "Door(s) Open", text = message, } } local response, code = fibaro.homeCenter.notificationService.publish(request) fibaro.debug("Scene109", json.encode(response)) fibaro.debug("Scene109", code) end The debug responses are: for response: {"data":{"title":"Door(s) Open","buttons":[],"text":"Alarm in kelder en begane grond armed"},"created":1586512755,"type":"MobilePopupNotification","id":208,"priority":"warning","wasRead":false,"canBeDeleted":true} for code: 200 My Notification page in the web interface displays the warning as "Notification title" but no mobile notification is received. I also had this scene running with fibaro.alert() but that did not give me the desired large popup, only a smal one with limited text and not button options. BTW: I couldn't get the button functionality to work in any way. Tried arrays, objects, array of objects, object of objects etc but always got an error code 400 or simply a load error code ((load):34: unexpected symbol near '[') So, can anybody point me in the right direction, or tell me if what I want is possible in HC3? Thanks a lot
- 2 replies
-
- mobilepopupnotification
- lua
-
(and 1 more)
Tagged with:
-
Witam, Ciekaw jestem, czy można napisać scenę LUA, która da odpowiedź w formie debug lub wyśle rezultat na maila odnośnie wyszukania, w których scenach znajduje się, jest użyte dane ID urządzenia. Np. chcę poszukać, w których scenach jest załączane lub wyłączane światło przed domem o ID 1101. Wiem, że jak wejdę w urządzenie o ID 1101, to zobaczę wynik dla if lub then ale okazuje się, że nie są to wszystkie sceny... Pozdrawiam, Łukasz
-
I have moved to the HC3 and trying to work out how the LUA programming works. The HC2 programming seemed a lot more logical and I am struggling to work out how to convert some of my old routines over. One of the first routines is remotes. Setting this up by blocks wouldn't work as it looks like I'd have to setup a scene for each button for each remote. Could someone help tell me how to convert this simple program into a HC3 computable version? --[[%% properties13 sceneActivation%% globals--]]local buttonPressed = fibaro:getValue(13, "sceneActivation")if ( tonumber(buttonPressed) == 1) thenfibaro:debug("MiniMote button 1 pressed")elseif ( tonumber(buttonPressed) == 2) thenfibaro:debug("MiniMote button 2 pressed")elseif ( tonumber(buttonPressed) == 3) thenfibaro:call(4, "turnOn")fibaro:debug("MiniMote button 3 pressed - Light ON")elseif ( tonumber(buttonPressed) == 4) thenfibaro:call(4, "turnOff")fibaro:debug("MiniMote button 4 pressed - Light OFF")elseif ( tonumber(buttonPressed) == 5) thenfibaro:debug("MiniMote button 5 pressed")elseif ( tonumber(buttonPressed) == 6) thenfibaro:debug("MiniMote button 6 pressed")elseif ( tonumber(buttonPressed) == 7) thenfibaro:debug("MiniMote button 7 pressed")elseif ( tonumber(buttonPressed) == ? thenfibaro:debug("MiniMote button 8 pressed")elsefibaro:debug("No response")end Thanks
-
I'm using a ZRC-90EU and everything works fine but I don't like the way I need to assign a action to a button (function). As you can see in the picture, in the Advanced page of the device you can assign an action to each button but you have to start from scratch every time (I can not assign an existing scene to a button).... With a block scene it is possible as well but if you want to assign 1 function/scene to one button and you know that every button has 4 options (1x,released, held and 2x) than I have to create 32 scenes.... I am new and have a HC3 so I never had HC2, HCL .... but once I've seen a LUA script that contained all button options and in the script it was possible to assign a function/scene to every possible option per button within that script so you could assign existing scenes as well. I already tried some HC2 LUA scripts and they don't work in HC3 so copying the script from HC2 isn't an option (+ I can(t find it anymore ) Does someone have a solution so I can use a LUA script or a QA to assign functions/scenes to the buttons without creating a new scene per button .... ? Thank you
-
Yes/no and run/cancel are the only options when using block scenes. Can I use LUA to make an interactive push notification that lets me choose between 2 or more scenes to run? If so, how?
-
response, status = api.get("/scenes") fibaro:sleep(1000) if (status == 200) then fibaro:debug("Get Scenes Successful") created = true else fibaro:debug("Failed to get Scenes " ) end for _,s1 in ipairs(response) do local s2 = api.get("/scenes/"..s1.id) if s1.name == gSceneName then fibaro:debug("SceneName: " .. s1.name .. " Scene ID: " ..s1.id) print (s1.isLua) -- ** gets correctly print (s1.lua) -- <=== RETURNS a null --- HOW do I get this print (s1.roomID) -- ** gets correctly print (s1.iconID) -- ** gets correctly print (s1.sortOrder) -- ** gets correctly SceneID= s1.id fibaro:sleep(1000) Essentially I'm trying to get the Lua code from a scene so I jason encode it so I can then populate another scene with the same lua code. I'm trying to automatically update/create Lua scenes without having to go in and edit each one individually. I can populate the "lua " field with an API PUT ... But I can't read it back. The code above returns all the other fields but not the s1.lua Any help would be greatly appreciated - thanks.
-
Witam, Scena LUA utworzona ze sceny blokowej mi nie działa. Tak w danym moncie aktywna jest tylko jedna z dwóch scen. Scena blokowa: Utworzona z niej scena LUA: Ktoś ma pojęcie o co chodzi?