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 'Scenes'.

  • 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. Good evening. Please let me know if there is a possibility for the Home Center Lite equipment to make a scene so that when the front door opens a room will send me a photo of who entered or left the house. I mention that at HC2 and HC3 I created this scene and it works. At HCL, even if there is a correctly configured and functional camera in the device, my camera does not appear in the scenarios when I want to configure when opening the door to send a photo by mail. May? how come? Thanks
  2. 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.
  3. Hi all, I've set up irrigation control of four valves using two double switch 2 units in Eutonomy enclosures. The pump has a separate power supply and switch. The double switch 2 units are set up as irrigation controls in HC3. The control box is located in my shed with a 5-wire cable running to the valves. I'd like to see if I can use push buttons on the S1/S2 inputs to trigger a scene for irrigation control - eg, S1 on the first switch would trigger a scene that runs the pump and commands the valve for zone 1 to open for 30 minutes. While I can set up actions for S1/S2 when the switch is set up as a switch in HC3, I don't see these controls for a switch that is set up as irrigation control. Is there a way to achieve this? Thanks!
  4. Hi, I have 142 HCL's in my project and 142 Echo dots 3, with 16 devices and 59 scenes. Some I managed to find all devices and scenes perfectly, but I'm having trouble in the vast majority. The HCL that worked is exactly the same as the HCL that doesn't work, I've seen that this is an old and recurring problem, my project can stop due to this. Has anyone managed to resolve this? Thanks
  5. Hello, I'm trying to "convert" this LUA script in a scene, but my trouble cames from the fact that I don't know how to send an http request in a scene. Here is the script I use in a device (and it works find): local texte = string.format("%s %s", tostring(os.date('%H:%m', os.time() )), "HC3 : This is a test.") local address = string.format("http://192.168.0.0/write?color=%s&bg=%s&t=%s", "black", "white",texte) http:request(address, { options={ method = 'GET' }, success = function(response) print(response.data) end, error = function(error) self:debug('error: ' .. json.encode(error)) end }) The goal, is to send a time stamped notification in a remote web server when a scene is launch, but maybe I'm on a wrong way ? Thanks for your help. Alex.
  6. Would it be possible to add a Description Field in the Conditions / Triggers : This would be very useful in scene creation and debugging. Example: { operator = "any" conditions = { { type = "device", id = 25, property = "value", operator = "==", value = true, duration = 20, isTrigger = true description = "MyDescription1" },{ type = "device", id = 26, property = "value", operator = "==", value = true, isTrigger = true description = "MyDescription2" } } Example code: local triggerDescription = json.encode(sourceTrigger.description) if triggerDescription == "MyDescription1" then print("Action 1 Triggered scene") elseif triggerDescription == "MyDescription2" then print("Action 2 Triggered Scene") else print("Something else triggered the scene") end
  7. (I'm a n00b. Using a Home Center 2) I have a space where I want any one of three (motion) sensors to be able to switch lights on, and when not more activity has been sense for some time, switch them off. I'd like to extend it such that the lights only come on between sunset and sunrise. I have created 4x scenes, 3x Turn On, 1x Turn Off. The logic I am using is: I created a Global Variable (called LastOnTime) to track the last activation/on time. All of the motion sensors trigger a scene that turn the lights on; and set the LastOnTime to os.time() - I have three copies of that scene. I created one more scene that is triggered off a timer; then if [os.time() - LastOnTime] > 600 turn the lights off. The scripts are below. Questions I have are: is this a good way of doing it? is there a better way? the timer is not working (the scenes are not triggered). I found this 'hack' somewhere in this forum. how do I put something here to check os.time() > [sunset] ? ---------- The On scenes look like: --[[ %% properties 58 value %% weather %% events %% globals --]] local minLight = 100 local motionSensorName = 'F438944-Motion' local motionSensorId = 58 local luxSensorId = 60 fibaro:debug('Lights On - ' .. motionSensorName .. ' (' .. motionSensorId .. ')') local startSource = fibaro:getSourceTrigger() local currentTime = os.time() local deviceStatus = tonumber(fibaro:getValue(motionSensorId, "value")) local currentLux = tonumber(fibaro:getValue(luxSensorId, "value")) fibaro:debug('Device Status: ' .. deviceStatus ) fibaro:debug('currentTime: ' .. currentTime ) fibaro:debug('Lux: ' .. currentLux ) if ( (deviceStatus >= 0) and (currentLux < minLight) ) then fibaro:debug('Turn On Lights') fibaro:call(20, "turnOn") fibaro:call(24, "turnOn") fibaro:debug('Set Global Variable (LightsOnTime) to ' .. currentTime) fibaro:setGlobal("LightsOnTime", currentTime) end fibaro:debug('Complete') The Off script looks like: --[[ %% properties %% events %% globals %% time log *00:01 zoneAlights --]] local currentTime = os.time() fibaro:debug('currentTime: ' .. currentTime ) local lastOnTime = fibaro:getGlobal("LightsOnTime") fibaro:debug('lastOnTime: ' .. lastOnTime ) local delta = tonumber(currentTime) - tonumber(lastOnTime) fibaro:debug('delta: ' .. delta ) if delta > 600 then fibaro:debug('Turn Off Lights') fibaro:call(20, "turnOff") fibaro:call(24, "turnOff") end
  8. cag014

    All about icons

    Version 3.1

    15,004 downloads

    Did some rework on Fibaro and Aeon sensors icons and few others The stand alone sensor icon actually has a little human figure stand still (white color) to use as part of inactive motion icon. Added linear icons
  9. Hello seniors and comrades, i have a virtual device for iEast stream pro and i would like to Use the Playlist Function buttons to play Music in my Scenes but i have no idea how to do it. i don't know how to make and add music in the playlists. i can only play through USB Button function. i have tried searches but nothing, and this forum is my only hope i got. Lua Code in the Playlists: -- Play Preset #1 local command = "/httpapi.asp?command=MCUKeyShortClick:1"; local selfId = fibaro:getSelfId(); local ip = fibaro:get(selfId, 'IPAddress'); local port = fibaro:get(selfId, 'TCPPort'); local connection = Net.FHttp(ip, port); connection:GET(command) fibaro:call(selfId, "setProperty", "ui.labelState.value", "[preset 1]"); See the attached is my VD for iEast Stream Pro Looking forward for your kindness and help. Thank you all.
  10. Hello, I have been trying different ways of writing the following scene and each method I have tried doesn't work the way I want. What I want is - If it is 21:30 and Chicken Coop Light is On Then Send push notification. Seems simple but in the above format every time the light is turned on regardless of time, the notification is sent. If I reverse the trigger so that If Light is on and time is 21:30 I will get the notification everyday at 21:30 regardless of whether the light is on or off I've tried splitting the scene over two scenes, Scene 1 would be 'At 21:30 run scene 2' Scene 2 would be 'If light on then send notification' and I get the notification everyday at 21:30 regardless of time. Any suggestions? Thanks
  11. Hi All, Please guide me to right way to get args in scene on HC3 HC2 code to get scene args was: local args = fibaro:args() on HC3 it not working now Tried: local args = fibaro.args() -> got error: attempt to call a nil value (field 'args') local args = fibaro:args(). -> got error: attempt to call a nil value (method 'args') LUA editor don't show any functions containing "args".... Help, please... Thanks
  12. My apologies if this is already described, I did search, honest! I've added an Aeotec WallMote Quad to my HC3 and configured the buttons, now I'm adding a second one to the far side of the same room, so want some of the buttons to perform the same functions. How do I link a button to an existing scene? When I try to add a function to a button (Under Devices, [The remote in question], Advanced) the only option seems to be to create a new scene. Many thanks in advance!
  13. It looks like I can set up a scene to react to events. How can I tell what events a particular ZWave device sends that I can wire a scene to? (How are these different from changes of property value?)
  14. Version 1.0.0

    1,768 downloads

    More then 300 scene icons
  15. While working from home for eight months now I had the need to toggle a light or run a scene from my Windows 10 laptop. After some Google I didn't find an app so I decided to learn basic C# and create a Windows tray application myself. The application loads your configured rooms, devices and scenes from your HC2/HC3 and puts them in a menu in the system tray. Now you can run a scene or toggle a light switch without reaching for a wall switch or your phone. ? The program looks like this: I Iearn and get a lot from the Fibaro community, therefore I made the code open source on GitHub. You can download the application from the releases page. You only need the .exe file. I don't own a HC3. If it also works on the HC3 please inform me. Than I add it to the documentation.
  16. Hi, I've just got my HCL and installed the Hue plugin. I see all lights - and I am able to control them - on the main device page, though when I try to make a new scene (from blocks) the lights are not included in the device list? Please find images attached. Q: How do I get them to show up, within the scene builder?
  17. Hi all, I'm trying to build several alarm scenes using the graphical block builder (will be switching to LUA soon). Part of what I want to do is to receive Push Notifications on my mobile device (Android phone) but when I try to select my registered mobile device under the Notifications menu, nothing is listed. I've checked that my phone is listed under Configuration > Access Control and can see it listed there under Mobile Device List, with a tick in the checkbox to receive notifications I should add, that if I create a scene that is triggered by the GPS location of a mobile device, then my phone IS recognized there..... Any ideas?
  18. As has been re-iterated many many times on this forum, there are two methods of updating a slider in a virtual device from a scene or another VD: Using fibaro:call(device, "setProperty", "ui.sliderX,value", value) causes the numerical value of the slider to be updated, but not the length of the slider bar. Neither does it execute the code behind the slider. Using fibaro:call(device, "setSlider", X, value) causes the numerical value and the length of the slider to be updated,, and executes the code behind the slider. In both cases, "device" is the ID number of the VD, "X" is the slider reverence number and "value" is the new slider value (0-100). Generall, option 2 is preferred because everything is updated. However, there seems to be an issue if the VD has more that nine sliders. Executing a few lines of test code for each of the methods illustrates this. First, method 1. Executing this code: local device = fibaro:getSelfId() local sliderString1 local sliderString2 local numSliders = 13 fibaro:debug('-----------------------------------------------------------') fibaro:debug('--Set Sliders----------------------------------------------') for i = 1, numSliders do sliderString1 = ('ui.Slider' .. tostring(i) .. '.value') fibaro:call(device, "setProperty", sliderString1, tostring(i)) fibaro:debug('Slider ' .. tostring(i) .. ' = ' .. tostring(i)) end fibaro:debug('--Read Sliders---------------------------------------------') for i = 1, numSliders do sliderString1 = ('ui.Slider' .. tostring(i) .. '.value') sliderString2 = fibaro:getValue(device, sliderString1) fibaro:debug(device .. ', ' .. sliderString1 .. ' = ' .. sliderString2) end Gives: [DEBUG] 16:21:04: --Set Sliders---------------------------------------------- [DEBUG] 16:21:04: Slider 1 = 1 [DEBUG] 16:21:05: Slider 2 = 2 [DEBUG] 16:21:05: Slider 3 = 3 [DEBUG] 16:21:05: Slider 4 = 4 [DEBUG] 16:21:05: Slider 5 = 5 [DEBUG] 16:21:05: Slider 6 = 6 [DEBUG] 16:21:05: Slider 7 = 7 [DEBUG] 16:21:05: Slider 8 = 8 [DEBUG] 16:21:05: Slider 9 = 9 [DEBUG] 16:21:05: Slider 10 = 10 [DEBUG] 16:21:05: Slider 11 = 11 [DEBUG] 16:21:05: Slider 12 = 12 [DEBUG] 16:21:05: Slider 13 = 13 [DEBUG] 16:21:05: --Read Sliders--------------------------------------------- [DEBUG] 16:21:05: 1044, ui.Slider1.value = 1 [DEBUG] 16:21:05: 1044, ui.Slider2.value = 2 [DEBUG] 16:21:05: 1044, ui.Slider3.value = 3 [DEBUG] 16:21:05: 1044, ui.Slider4.value = 4 [DEBUG] 16:21:05: 1044, ui.Slider5.value = 5 [DEBUG] 16:21:05: 1044, ui.Slider6.value = 6 [DEBUG] 16:21:05: 1044, ui.Slider7.value = 7 [DEBUG] 16:21:05: 1044, ui.Slider8.value = 8 [DEBUG] 16:21:05: 1044, ui.Slider9.value = 9 [DEBUG] 16:21:05: 1044, ui.Slider10.value = 10 [DEBUG] 16:21:05: 1044, ui.Slider11.value = 11 [DEBUG] 16:21:05: 1044, ui.Slider12.value = 12 [DEBUG] 16:21:05: 1044, ui.Slider13.value = 13 As would be expected. However executing a code snippet using method 2, like this: local device = fibaro:getSelfId() local sliderString1 local sliderString2 local numSliders = 13 fibaro:debug('-----------------------------------------------------------') fibaro:debug('--Set Sliders----------------------------------------------') for i = 1, numSliders do fibaro:call(device, "setSlider", tostring(i), tostring(i)) fibaro:debug('Slider ' .. tostring(i) .. ' = ' .. tostring(i)) end fibaro:debug('--Read Sliders---------------------------------------------') for i = 1, numSliders do sliderString1 = ('ui.Slider' .. tostring(i) .. '.value') sliderString2 = fibaro:getValue(device, sliderString1) fibaro:debug(device .. ', ' .. sliderString1 .. ' = ' .. sliderString2) end Give this: [DEBUG] 16:43:02: --Set Sliders---------------------------------------------- [DEBUG] 16:43:02: Slider 1 = 1 [DEBUG] 16:43:02: Slider 2 = 2 [DEBUG] 16:43:02: Slider 3 = 3 [DEBUG] 16:43:02: Slider 4 = 4 [DEBUG] 16:43:02: Slider 5 = 5 [DEBUG] 16:43:02: Slider 6 = 6 [DEBUG] 16:43:02: Slider 7 = 7 [DEBUG] 16:43:02: Slider 8 = 8 [DEBUG] 16:43:02: Slider 9 = 9 [DEBUG] 16:43:03: Slider 10 = 10 [DEBUG] 16:43:03: Slider 11 = 11 [DEBUG] 16:43:04: Slider 12 = 12 [DEBUG] 16:43:04: Slider 13 = 13 [DEBUG] 16:43:04: --Read Sliders--------------------------------------------- [DEBUG] 16:43:04: 1044, ui.Slider1.value = 10 [DEBUG] 16:43:04: 1044, ui.Slider2.value = 11 [DEBUG] 16:43:04: 1044, ui.Slider3.value = 12 [DEBUG] 16:43:04: 1044, ui.Slider4.value = 13 [DEBUG] 16:43:04: 1044, ui.Slider5.value = 5 [DEBUG] 16:43:04: 1044, ui.Slider6.value = 6 [DEBUG] 16:43:04: 1044, ui.Slider7.value = 7 [DEBUG] 16:43:04: 1044, ui.Slider8.value = 8 [DEBUG] 16:43:04: 1044, ui.Slider9.value = 9 [DEBUG] 16:43:04: 1044, ui.Slider10.value = 10 [DEBUG] 16:43:04: 1044, ui.Slider11.value = 11 [DEBUG] 16:43:04: 1044, ui.Slider12.value = 12 [DEBUG] 16:43:04: 1044, ui.Slider13.value = 13 Which is clearly wrong. Is this a bug, or have I done something really dumb (if so please enlighten me). If it is a bug, does a workaround exist? TIA.
  19. Hi all Is there a fibaro killscene and startscene command similar to hc2? Thanks
  20. Hello, I need a help. I can see more ways od forum and marketplace for override heating zone, but they are to complicated for me. I need simple scene (or virtual device??) which will set all heating zones to specific temperature for specific time and after that back to schedule. Why I need this? I have central heating system with wood and water acumulation puffer. Sometimes temperature in system increase to high and for security reasons I need to cool down system. I made scene which control temperature in system and send me notification when temperature is too high. Notification ask me if I want to run some scene. Here I want to open all radiators. Or, if somebody have another idea, maybe I don't need override heating zone. I have Fibaro heat controller on all radiators, but I don't know how to open it to max with scene. Thank you in advance.
  21. Hi, Pretty basic question but I have searched the forum (and web) and not been able to find any solution that can help me. I have created a variable, Home_Away with two values; Home and Away. I then built two simple block scenes that says says that if a wall plug is ON it should switch to HOME (and OFF gives AWAY). I have then a ZRC-90 remote controller that puts the wall plug in in on (button 1) and off (button 2) mode. So far so good. I have then tried multiple times and in different ways to build a simple scene that should run and turn on a window light at a certain time when I'm not home (when I'm home I want to control the light myself). I have then built an additional scene that should turn the light off automatically at a fixed time when I'm not home. This doesn't work the way I want it at all... For instance, if the light is off and I put the wall plug in off (Away) mode the light still turns on - I don't want it to turn on until both conditions are met (time and variable). Adding to this is that the scene to turn it off doesn't seem to work either so I guess I'm missing some fundamental part here? Scene to turn on light below: Scene to turn off light below I can also add that my intention is to continue building from this logic to have multiple lightning scenes that only runs when the house is in Away mode. Many thanks in advance for any type of guidance!
  22. Hi guys, I seem to be missing something very basic... And wonder if anybody could give me a pointer. I want to do something as simple as this. 1) When movement is detected: Turn on the light 2) When there has been no movement for x seconds: Turn off the light (where x will be different for the different areas, e.g. from 15 seconds to 5 minutes) So I create two scenes (using the graphic blocks) 1) Turn on lights, (IF motion == Breached 0s) THEN (Turn on Lights) 2) Turn off lights. (IF Motion == Safe 60s) THEN (Turn off lights) But very frequently in my log, I see "Too many instances of the turn-off scenes". Which got me thinking. If I understand correctly, a new instance of 2) will be started every the sensor triggers that motion stops. So If I'm in the scene, and then move again within 60 seconds, scene 1) will be triggered again (but doing nothing, as the light is already on). When I stop moving again, yet another instance of 2) will be started. And then eventually, the max number of triggers are reached, which causes the error. The longer the timeout is, the more possible instances of 2) may be running. So I guess I could increase the number of instances, but is this really a good idea? Or am I going about this the wrong way? Should I instead create a LUA (which I haven't tried yet, but have a lot of programming experience), with the following two scenes: 1) Scene motion (motion == breached) Set global variable motion = yes if (number of instances > 1) exit Turn on lights while (variable motion == yes) wait 10 seconds while end turn off lights 2) No-motion (motion == safe 60s) set global variable motion = no Thanks for any advice on this. John Erik
  23. Dear gentleman, I have a problem with making a scene for ARM/DISSAR the system using the smart implant. I want to mention that my alarm system it is not a smart one. I will describe what I have done till now. I installed 2 relay on the alarm PGM exits to know the status of the system and to have a feedback if the alarm is activated. I use the smart implant as follow: 1. The OUT1 is connected to the ON/OFF impulse in order to ON and OFF the system. Each impulse will ON or OFF the system 2. The IN1 is connected as switch on the ARM/DISARM status. Basically if the relay it is open the system is DISARM and if relay is closed the system is ARM. 3. The IN2 is connected as switch for the thief alarm. Basically if the system it is ARMED and someone enter in the house this relay will be CLOSED and get a feedback. Relay = ON - ALARM and relay = OFF - NO ALARM Till now it is ok and it is works. My question is the scene. I did not succeed to make a correct scene. What I want to make it is next: 1. ARM the SYSTEM scene 2. DISARM the system scene To ARM the SYSTEM i've made a scenario like: if IN1= breached then OUT1 = On ... and the fibaro arm the system. To DISARM the SYSTEM it is similar - if IN1= safe then OUT1 = On the problem is that the system goes in to a loop. To avoid that I put a one time trigger like - OnceEg. Run Scene on 23/4/2024 at 12:30 at beginning of each scene. So in this case the system will not go on the loop but it seems that there is a mistake in my logic scheme because the if I run DISARM scene even if the IN1 is safe (meaning that the system it is already disarmed) the OUT1 give the ON impulse and arm the alarm. Please guys, be so kind and give me a solution. Thank you.
  24. I have three rooms with a Dimmer 2 in each. The dimmers are activated from motion detectors in each room. While cleaning I'd like to have the lights at full output and I have set parameter 19 to 90%. When activating the toggle switch the lights will go to 90% but when the motion sensor see a motion it will activate the scene dimming the lights to 8%. Is it possible to make S1 override all scenes as long as it is on? At the moment I turn the motion sensors towards the wall so they aren't activated but that is no sophisticated solution!
  25. Hi, After I put together the Virtual devices Introduction Tutorial I was asked would I do something similar for Scenes. I’ll preface this post (like the Virtual devices) that I am no expert but I am willing to document what I understand and it can be added to over time. It would be great if some of the experst could read through, fill in the coupelof gaps and let me know if I havesomething wrong or coudl do with better explanation I also start at a very basic level as some of the newer users people liked that with the virtual device tutorial I am also only going to Lua scenes as I have never worked with Magic Scenes or Graphics Blocks Scene Basics A scene is a mechanism to execute a lua code script for an on-demand basis. General Tab Name, Room - self explanatory ID – set when the scene is saved, doesn’t change for life of scene. This is the unique identifier for this scene and can be used as part of the startScene command fibaro:startScene (ID) Max number of instances – A scene can be called from a number of different sources. This dictates how many instance of the scene can be running concurrently. This can also be set within the scene using lua. I’m not sure if these two settings are in conflict which one takes priority. if (fibaro:countScenes()>2) then fibaro:abort() end -- or if (fibaro:countScenes()>1) then fibaro:debug("stop scene") fibaro:abort() end Lili commands – voice control for running/stopping scene using Lili who is the native HC2 personal assistant. Run Scene Automatic – it can be called from other scenes or run manually Manual – it can be called from other scenes or run manually (unsure what the difference is between manual and automatic) Disabled – scene cannot be run Scene Hidden: Not visible in the Web UI (unless you select HC2 hidden devices) Protect by Pin: Prompted for PIN CODE if scene is set to running Do Not Alarm to Stop: ??? Change Icon – select a new icon to display alongside the scene (128x128 png transparent) Advanced Tab Lua Window The code in the lua window is the defaulst header for any scene and needs to be kept. Debug window (debug output from scene code when it is run) START – Start the script running STOP – Stop the script running CLEAR – Clear the debug window Web UI View 1. Title of scene 2. Edit 3. Delete (confirmation req) 4. Icon 5. Disable/enable 6. Run/Stop scene 7. Status – populated by fibaro:log command Lua Scene Header The header of a scene always contains some of all of the following. These are used to trigger the scene in a number of different way. --[[ %% autostart %% properties %% events %% globals --]] %%autostart – including this means that the scene will run when it is saved or when the HC2 restarts. $$ properties – the user can add a device ID and parameter. Any change to this parameter will trigger/run the scene. The format is ID following by parameter. --[[ %% autostart %% properties 1429 value %% events %% globals --]] In the example above if 1429 was a door sensor and value was the status parameter that changed (0 <-> 1) when the door opened than any status change would cause the scene to run. This has to be the device ID and cannot be a variable that represents the ID %%events – ?? %%globals – the user can add the name of global variable (exactly and case sensitive). Any change to the value of the global variable will trigger/run the scene An example would be --[[ %% autostart %% properties %% events %% globals G_AREA__1 --]] A scene can be setup to trigger from properties, events or global variables The following code allows a different action depending on the trigger if this is what’s required. -- Trigger Management local currentDate = os.date("*t") local startSource = fibaro:getSourceTrigger() --Start of Scene Execution if (startSource["type"] == 'property') then fibaro:debug("Started through property") tempFunc1() -- this is calling the the function if something happens. elseif (startSource["type"] == 'global') then fibaro:debug("Started through variable") tempFunc2() -- this is calling the the function if something happens. elseif (startSource["type"] == "autostart") then fibaro:debug("Started through autostart") tempFunc3() -- this is calling the the function if something happens. elseif (startSource["type"] == "other") then fibaro:debug("Started through other ") tempFunc4() -- this is calling the the function if something happens. else fibaro:debug("Scene not started, this can only be started through other, property, global or autostart!"); end In the example above the following happens Scene triggered from property (1425 value) - it will execute function1() Scene triggered from global variable(sleepState) - it will execute function2() Scene triggered from an autostart - it will execute function3() Scene triggered from any other valid method - it will execute function4() or else the scene will no start Local Variable declaration These are variables tha you intend to use within the scene. You can also use global variable but these do not need to be declared prior to usage Many people put the local variable declaration at the start of the scene followed by the functions -- example of local variable declaration local HC2email = "true" -- Notification Alerts using Fibaro email service local HC2popUp = "true" -- Notification Alerts using Fibaro popup service notifications local pushOver = "false" -- Notification Alerts using Pushover Notification Service (Tutorial by AutoFrank) local ALLINONE = "false" -- Notification Alerts using 'All in one Notification' scene (created by jompa68) local updateData = "false" -- Set to true to update the data in the table. ** SET BACK TO FALSE ONCE COMPLETE ** Code Comments Comments /explanations in the code are very useful as the allow you to explain what the code is doing to either yourself or others You need to preface or encapsulated all comments to prevent them being executed at runtime. Example of single line and multi-line comments are shown below -- Example of a single line comment --[[ example of a multiline comment where the sentence spans one or more lines in the scene --]] In general all scenes will have the following structure but over time most people develop your own style … --[[ %% autostart %% properties %% events %% globals --]] if (fibaro:countScenes()>2) then fibaro:abort() end -- explanation of the code purpose or usage or installation -- local variable declarations -- functions -- Main Code sequence (calling the functions above) Lua command syntax is generally the same whether it is used in a scene or used in a virtual device (exceptions to this are http requests) Some useful lua command if fibaro:getGlobalValue("Occupancy_HOUSE") == "no" -- compare global value if fibaro:setGlobal("Alarm_TrigCount", "0") then -- setting global value if tonumber(fibaro:getValue(GardenSensor, "value")) == 1 -- get device status value fibaro:startScene(AlarmSet) -- Start a scene fibaro:call(1387, "pressButton", 10) -- press a button on a vd fibaro:debug("Notify Alert! "..jN[i].device.." is offline") -- print a mix of variable and text string fibaro:call(2, "sendEmail","Alert!", "Garden Sensor triggered") -- send email using HCC2 native email service -- HC2 native popup notirfication service HomeCenter.PopupService.publish({ title = 'Home Alarm Activated ', subtitle = os.date("%I:%M:%S %p | %B %d, %Y"), contentTitle = 'Zones Status', contentBody = fibaro:getGlobalValue("G_SPC_AREA_STATUS_1"), type = 'Success', }) Some useful lua functions ENCODING - replace a space in a string with another character, a + symbol in the example below This function takes one parameter - s so The Cat and the Mat will be changed to The+Cat+and+the+Mat -- function to replace a space in a text string with a + function urlencode(s) if (s) then s = string.gsub (s, "\n", "\r\n") s = string.gsub (s, "([^%w ])", function (c) return string.format ("%%%02X", string.byte(c)) end) s = string.gsub (s, " ", "+") end return s end test = urlencode(message) ROUNDIT Rounds a number to a defined number of decimal places This function takes one parameter - num (the number you want rounded) and idp (the number of decimal places) so roundit(2.12348, 3) would result in 2.123 function roundit(num, idp) local mult = 10^(idp or 0) return math.floor(num * mult + 0.5) / mult end If there are any other useful functions that you feel would be of benefit to new users please let me know and I'll include them Overall the best way to gain a greater understanding is to download the many scenes that are published to the forum and start to take them apart. I hope this will be of benefit to some users and suggestions and corrections are always welcome happy coding -f
×
×
  • Create New...