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


  • 0

Basic Code Clips for LUA starters


Question

Posted

To help those that are not familiar with LUA a starter library of clips that work in Fibaro.

Please add any you find useful.

  • Answers 151
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

Posted Images

Recommended Posts

  • 0
Posted

You are thinking - triggering variables - uncheck?

  • 0
Posted

Lauri, yes, because you want every time to start scene when variable got specific value right?

  • 0
Posted

Yes - another scene is affected by this variable and I want this to keep 5hour brake before start running again (alarm + camera pictures - this way inbox is not filled with pictures)

[ Added: 2013-10-08, 09:10 ]

I checked today, and it has worked.. I used 5hour interval! Good

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

  • 0
Posted

in 3.572

Please login or register to see this code.

will return ID of virtual devices

  • 0
Posted

Hi,

What code do I need to change a variable (on/off) with a button?

I need a virtual device I think. Is it possible to have a message or a visual aid to see if it is on or off?

I have a wakeup light for my daughter and sometimes it is not necessary to go on, so i would like to manually disable it.

So I made a variable and a scene that looks if the variable is on or off. I only need the switch now

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

thanks in advance

Aaron

  • 0
Guest jschun
Posted

I'm a LUA newbie (a scripting newbie actually) But I made the following script to turn on the heating in the bathroom before I take a shower, so that it is nice and warm before I go and undress to step in the shower. Fibaro notifies when the pre-heating is done and I can go have a shower.

Please feel free to comment and adjust to your hearts content

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

Please login or register to see this code.

[ Added: 2013-11-24, 11:08 ]

I created this scene to control my light on the toilet. I first used the script posted in this thread, but I wanted something that does't need to arm and disarm my sensor. So I wrote this. Please keep in mind that I just work with this scripting language for two weeks or so. So any improvements or creative comments are always welcome.

Please login or register to see this code.

  • 0
Posted

i need to add a virtual device that uses the temperature of my srt321 thermostat. as i'm a newly on LUA i wonder if somebody can give me a hand. i would like to create a virtual device that shows the measured temperature of thermostat so that i can use this virtual device to start my heating panel.

Thanks

  • 0
  • Inquirer
  • Posted
    i need to add a virtual device that uses the temperature of my srt321 thermostat. as i'm a newly on LUA i wonder if somebody can give me a hand. i would like to create a virtual device that shows the measured temperature of thermostat so that i can use this virtual device to start my heating panel.

    Thanks

    not exactly sure what you are after but this bit of code might help

    Please login or register to see this link.

    It is used to heat my water cylinder based on the temperature of my cold header tank and the top and bottom of the cylinder.

    The colder the header the hotter the cylinder so the temperature at the tap stays constant at the same hot to cold mix.

    Uses a fibaro module for heat demand and universal sensor and temp probes for temperatures.

    Please login or register to see this code.

    • 0
    Posted

    Add the necessary libraries at the top of the page: Toolkit, Toolkit.Debug and Toolkit.Net

    All informations can be found here:

    Please login or register to see this link.

    Example: call rest API (Freebox V6, French ISP box) with custom headers...

    Please login or register to see this code.

    • 0
    Posted

    HC2 = Net.FHttp("192.168.100.xx",80)

    --your hc2 login data

    HC2:setBasicAuthentication("admin", "admin")

    [/code]

    It appears Net.FHttp(ip, port) is not available in Lua scenes. I'm getting

    [ERROR] 15:21:14: line 10: attempt to index global 'Net' (a nil value)

    Is that right? Is there any reason? Is there any other way to access the JSON API in general through Lua scenes?

    • 0
    Posted

    Just work in virtual device

    • 0
    Posted

    (For instance, if you happen to have your cats litter box in a bath room/toilet or such)

    Basically, if the door is closed for more then X seconds, send a push notification to the mobile client on my and my spouses phones. Crude code, but it's my first scene.

    --[[

    %%autostart

    %% properties

    69 value

    %% globals

    --]]

    local sensorID = 69;

    local sceneID=9;

    local MaxClosedTimeInSeconds = 900;

    local debug = true;

    local pushMsg = "The door to the litter box appears to have been closed for too long";

    if (debug) then

    fibaro:debug ("Sensor "..sensorID .. " value is " .. fibaro:getValue(69, "value"));

    fibaro:debug("Running Scenes: ".. fibaro:countScenes(sceneID));

    fibaro:debug(" getSourceTriggerType: "..fibaro:getSourceTriggerType());

    end

    if (fibaro:countScenes(sceneID) == 1) then

    if (fibaro:getValue(sensorID, "value") == "0") then

    if (debug) then fibaro:debug("The door is closed"); end

    fibaro:sleep(MaxClosedTimeInSeconds*1000);

    if (fibaro:getValue(sensorID, "value") == "0") then

    if (debug) then fibaro:debug("The door is still closed, pushing notification!"); end

    --The ID's below needs to be changed to match your phones.

    fibaro:call(12, "sendPush", pushMsg);

    fibaro:sleep(10000);

    fibaro:call(19, "sendPush", pushMsg);

    end

    end

    else

    if (debug) then fibaro:debug("Scene is already running. No action taken."); end

    end

    • 0
    Posted

    A script to check if it is day or night. I saw some posted scripts that set a global variable at sunrise and sunset. But you don't have to set a global variable. You just convert sunrise time into seconds from midnight, sunset into seconds from midnight and current time into seconds from midnight. Then you do a check to see if current seconds from midnight is between sunrise seconds and sunset seconds. Code to explain:

    Please login or register to see this code.

    Didn't find anyone that had posted this yet.

    • 0
    Posted

    hi

    can you please help with Lua script to run scene from multiple clicks

    thanks in adv

    Naresh

    • 0
    Posted
    hi

    can you please help with Lua script to run scene from multiple clicks

    thanks in adv

    Naresh

    Here are a thread about multiple clicks. Maybe it can help you.

    Please login or register to see this link.

    • 0
    Posted
    example of Scene activation for dimmer

    change 507 for id your device

    Please login or register to see this code.

    Hello Socha,

    I tried this lua code but could not get it worked. I changed device ID and Scene ID for S2 single and double click.

    My requirement is simple. Want to run two scenes using S2 terminal. Single click, and double click.

    Any help is greatly appreciated.

    • 0
    Posted
    example of Scene activation for dimmer

    change 507 for id your device

    Please login or register to see this code.

    Hello Socha,

    I tried this lua code but could not get it worked. I changed device ID and Scene ID for S2 single and double click.

    My requirement is simple. Want to run two scenes using S2 terminal. Single click, and double click.

    Any help is greatly appreciated.

    Have you updated (Activated) parm 41 on the dimmer device?

    • 0
    Posted

    This is really a mess. Yes it's nice to find stuff by random that i can use here.

    But can't Fibaro or someone make this into something more organized? A searcable database or something with index?

    • 0
    Guest fat
    Posted

    I am trying to modify some code I was given in order to only use when it is dark so I want to only run the scene when a lux value = 0. The code I have is below and I was hoping someone could tell me where to put code and what code is needed to do this.

    Front Door ID = 4

    Entry Light = 23

    Lux Sensor = 38

    Below is the code

    Please login or register to see this code.

    I thought that if I added "and if (fibaro:getValue(LoungeLight, "value") == "0")" between if (fibaro:getValue(frontDoorID, "value") == "1") and then about half way down the code then it should work

    Thanks

    • 0
    Guest GG
    Posted

    Hi

    You should add:

    or if (fibaro:getValue(LoungeLight, "value") > "0")

    Also remove 38 value from the properties section at the top. No need to trigger the scene when lux value changes as you check it when the door opens.

    Hope you understand what I meen.

    Ulf

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.


    ×
    ×
    • Create New...