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 'functions'.
-
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..
-
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 !!!
-
I have come across several Fibaro LUA functions that do not seem to be documented in the available Fibaro LUA manual. Here are a few examples: fibaro:getName(id) fibaro:getRoomNameByDeviceID(id) The use of formatting codes in fibaro:debug("text") And fibaro:call(id, "sendPush", "text..") and similar commands for e-mail etc. I have successfully used all of these and probably more. I am sure there are still more functions/calls out there which are only known from scenes published on the forum. Is there a more complete documentation available? Has anyone collected these semi-secret functions into a private document that may be shared?
-
I have written an enhancement scripts for boosting the heating in certain rooms based on presence. I already have a zwave boiler controller, and LC-13 radiators with a scripted running base heating scene.. The purpose of this is for certain rooms that meet the following criteria:- 1. Don't need to be heated to comfort level all the time in the heating panel 2. Presence is detected, and the user tends to be in the room for a good amount of time. 2 initial rooms for me are Study and Living Room I wrote it based on tabulated data, so I could just add additional information into the tables for inclusion, but my lua was "stretched" and there are a lot of loops in loops... it runs fine, but I wondered if anyone wanted to demonstrate how it SHOULD be written or if you want to use it, and you have radiator set points you would like to boost, feel free... heating_enhancement.txt
-
Hi, I’m relatively new to Lua and Fibaro. I have two questions about running Lua functions and accessing Lua tables from other scenes. Running Functions From Other Scenes: I have built a scene called "Initialise" which contains a collection of Lua functions. One of these functions is called Arm() and takes the parameter "_status" which indicates how the Intruder Detection System should be set. The "_status" can be: Disarm = disarms all motion sensors, door and window sensors Away = arms all motion sensors, door and window sensors Home = arms all the door and window sensors downstairs (does not arm motion sensors or upstairs window sensors) I want to call this Arm() function from other scenes, for example I want a scene called "Arm Away" which has a single line of Lua Arm("Away"), and another scene called "Arm Home" which has a single line of Lua: Arm("Home") and another scene called "Disarm" which has a single line of Lua Arm("Disarm"). This way I can have different scenes available to the user which are used to set the Intruder Detection System but I don't need to replicate the same code in all three scenes. Unfortunately this doesn't work. Although I run the “Initialise” scene which contains the Arm() function (but doesn’t contain any code to call the Arm() function) when I try to run my “Arm Away” scene (which contains a single line of Lua Arm(“Away”)) I get a message saying [ERROR] 12:59:57: line 1: attempt to call global 'Arm' (a nil value) Accessing Tables From Other Scenes I am trying to develop portability into my Lua code for home automation. One of the reasons for this is I have a Fibaro system in two houses and so having generic code which can just be ported into another Fibaro environment does not require any recoding is a real advantage. Another reason is so that if I add a new motion sensor to my house I don't need to change any code to make sure it is included in the code to Arm all the motion sensors. The way I achieve this is by naming all the zWave devices according to a standard. For example: M0_HALL_MS_01 is the first motion sensor in the Hall on the ground floor of the Main House, G1_BED2_WS_02 is the second window sensor in Bedroom 2 on the first floor of the Guest house. By building a table in Lua of all the devices I can work through that table looking for devices with “MS” in the name when arming all the motion sensors. So to the question – can I make this table of devices available to other Scenes (not just the “Initialise” scene which was used to create it?). I know how to use Fibaro Global Variables to make data available to multiple scenes but my question relates specifically to a table. I tried to research this online and from what I understand a Lua variable is local to a function unless it begins with “g_”. So my devices table is called g_devices. When I try to access this table from another scene I get a message saying [ERROR] 13:01:12: line 1: attempt to index global 'g_devices' (a nil value) I'd be grateful for any assistance or pointers anyone can provide.