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


Lua Christmas Lightszene or Light on so long movement, Change from HC2 to HC3


Recommended Posts

Posted (edited)

Hello everyone,

I'm just changing over and trying to implement the scenes mentioned in HC3.

What I quickly noticed is that you can't simply copy the Lua code from HC2, as HC3 apparently interprets the code differently.

I then created block scenes with the Sunrise function and wanted to merge this code into a Lua code.

Is it possible in this way, probably not really.

Please login or register to see this image.

/monthly_2024_12/image.jpeg.0e7ad5228a33a66f2cca25b2fe959eed.jpeg" />

Edited by Microby
Posted

Please read the forum rules, before posting in Spanish. 

  • Topic Author
  • Posted (edited)

    Hello,

    my language is not Spanish, but German. Sorry. I have changed it and hope that this is now OK.

     

    Where is my error in thinking here? The scenes run individually.

     

    Please login or register to see this attachment.

     

    I have built a block scene for each individual condition, i.e. "on in the morning" and "off after sunrise" and "on before sunset" and "off at night", which also work. I just wanted to summarize everything in one scene and only combined the Lua code from the individual scenes.

    Edited by Microby
    • Microby changed the title to Lua Christmas Lightszene or Light on so long movement, Change from HC2 to HC3
  • Topic Author
  • Posted

    The Szene "Light on so long movement" is a Timer-Szene.

    This is the code from the HC2:

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    23

    24

    25

    26

    27

    28

    29

    30

    31

    32

    33

    34

    35

    36

    37

    38

    39

    40

    41

    42

    43

    44

    45

    46

    47

    48

    --[[

    %% properties

    239 value

    253 value

    %% globals

    --]]

    -- VARIABLEN (Bewegungsmelder muss oben unter %% properties aufgeführt sein)

    local scene = 53 -- ID dieser Szene

    local motion = 239 -- ID des Bewegungssensors

    local switch = 485 -- ID des Relay Switches

    -- Lösche doppelte Szene(n)

    if (fibaro:countScenes()>1) then

     fibaro:abort();

    end

    -- SCHALTE LICHT EIN & AUS

    if (tonumber(fibaro:getValue(motion, "value")) > 0 ) and (tonumber(fibaro:getValue(switch, "value"))) < 1 then

     fibaro:call(switch, "turnOn");

     fibaro:debug("Schalte Licht ein");

    end

    -- Verzögerung in Sekunden (120 entspricht 2 Min) nach der letzten erkannten Bewegung, bevor das Licht ausgeschaltet wird

    if (tonumber(fibaro:getValue(switch, "value"))) > 0 then

     local starttimer = 120;

     local timer = (starttimer);

     fibaro:debug("Starte Timer");

     

     repeat

     fibaro:sleep(1000);

     -- Schalte Licht aus, wenn Schalter manuell betätigt wird und warte 10 Sekunden, um ein

     -- versehentliches (erneutes) Aktivieren der Szene zu verhindern

     if (tonumber(fibaro:getValue(switch, "value"))) < 1 then

     timer=1;

     fibaro:call(switch, "turnOff");

     fibaro:sleep(10000);

     break

     end

     timer=timer-1;

     -- Timer zurücksetzen, wenn neue Bewegung erkannt wird innerhalb der Verzögerungszeit

     if (tonumber(fibaro:getValue(motion, "value"))) > 0 then

     timer=starttimer;

     fibaro:debug("Resete Time, Bewegung erkannt bzw. Motionsensor sendet noch nicht (vgl. Parameter 6)");

     end

     until (timer<1)

     -- Schalte Licht aus, wenn Timer vollständig abgelaufen ist

     fibaro:call(switch, "turnOff");

     fibaro:debug("Timer abgelaufen/Schalte Licht aus");

     fibaro:killScenes(scene);

    end

     

    I have a Start-Timer not found in HC3

    Posted (edited)

    Hello, you didnt understand the LUA coding in the HC3 device, it´s a wrong...


    Very simply - the left part is/are the triggers (triggering condition) of the entire scene.
    The right part is the scene, the code that will be started/executed if the conditions in the left part are met.


    Try to learn it from the beginning - 

    Please login or register to see this link.

     

     

    Edited by Jiri Dobsovic
    Posted
    On 1/1/2025 at 4:29 PM, Microby said:

    Hello,

    my language is not Spanish, but German.


    😃

     

    Did you get it running?

  • Topic Author
  • Posted
    On 1/5/2025 at 12:18 PM, SmartHomeEddy said:

    Did you get it running?

    Hello,

    unfortunately not yet. It only works with lots of block scenes. I have not yet managed to combine it into one scene. For the Christmas scene, I have 4 per area where I set it, 1. morning on - at a certain time, 2. morning off - 10 minutes after sunrise, 3. evening on - 10 minutes before sunset and 4. evening off - at a certain time.

    And the Light so long movement, I have only had 2 block scenes so far. 1. motion detected - switch on, 2. light off if no motion - motion sensor no motion “true for 1 minute" then switch off.

    I'll try to read a bit more about Lua in HC3 when I have some time.

    Join the conversation

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

    Guest
    Reply to this topic...

    ×   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...