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

HC3 Lite Simple Scene (LUA)


john1312143

Question

Hi,

Is there any way to create ONE Scene block or LUA where you can execute more action based on conditions. I want to close my blinds on exact time and then on another time i want to open them, i now use two separate scenes for this scenario, it would be fine if i can join both scene into one, because of 20 scene Limitation. 

I am new in LUA and don't understand why there is two windows for conditions on the left and actions on the right, if there is one window where i can write conditions and immediately action, i would not ask this question.

I appreciate any simple example where are two conditions on the left and two actions on the right.

 

Thank you

 

 

Edited by john1312143
Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 0

There are several Lua solutions or maybe an all-in-one solution would suit you. 

 

But if you want to understand the basics of Lua a bit, you can start converting your two block scenes to two Lua scenes and look at them. There are also manuals for Lua:

Please login or register to see this link.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Figured it out by using time condition in action, if anyone have another solution dont hesitate to share :) , based on condition scene can be run automatically in the morning and evening(condition window on the left) and in the action based on current time i know now if i have to open or close blinds. However it would be nice to determine if the action was executed manually (when you want to close or open them during the day), is there any way to find out, so action conditions can be skipped?

    local timetest = os.date("%H:%M"),
    print("currentTime ",timetest)
    if(timetest > "19:30"then
        print(">19")
      --close blings
    end
    if(timetest > "07:20" and timetest < "07:30"then
        print("<8")
      --open blings
    end
    Link to comment
    Share on other sites

    • 0

    You could extend the if-statement with a status of your blinds: if the time > 19:30 and the blinds are open, then close them. (And the other way around with the open if-statement). 

     

    You can see the status of your blinds in for example the "Swagger" of your HC3 lite. That is an other function you can look at.

    I don't use blinds, I think it will be a number, but don't know for sure. 

    Link to comment
    Share on other sites

    • 0

    i give you different way, use souceTrigger to recognize WHICH condition triggered the scene, and based on result from sourceTrigger run the part of the code, which apply for the condition. In that way you can copy multiple conditions (triggers) from multiple scenes, into one bigger LUA scene, and run them from there

     

     

    EDIT: in principle everything what is in the trigger section in left window (like value= true), can be checked via sourceTrigger (if sourceTrigger.value == ) in right window (and based on result your code will be executed). 

     

    Edited by tinman
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @tinmanthank you that is exactly what i was looking for.  Is there any way that i have my own custom values in condition definition so i can check it in sourceTrigger.value mycustom value ?

     

    Please login or register to see this code.

    Please login or register to see this code.

    Edited by john1312143
    Link to comment
    Share on other sites

    • 0

    real custom value (as trigger type) is not supported, there is sort of on which the LUA scene engine will fire up (see below).

    But you can use custom-event as trigger type, e.g. another scene or quick app will send custom-event when something happens, and based on that your scene will trigger.

     

    Check that page,

     

    Please login or register to see this link.

     

    the first 1/3 is everything about triggers, sourceTrigger, conditions, etc.

     

    Link to comment
    Share on other sites

    • 0

    Actually the custom-event is exactly what Fibaro designed for us, to have own trigger source condition. Sure, custom-event does not have any additional values, but that in most cases not problematic (when i write something into variable and trigger on that, checking in the trigger section for specific value, like e.g. ismidnight, i can directly creat at mignight custom-event named "midnight" and trigger on that in my scenes). When you need to trigger one specific trigger type, but with different values, then you will have to use global variables (and write theirs values from a scene or QA) to get your scene triggered on taht specific global variable with specific value.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @tinman thank you, it is also possible to access weather condition on the right execution window ? i want to check weather in the morning if it clear then open blinds, now its working only in block scene.

     

    conditions = { {
          isTrigger = true,
          operator = "==",
          property = "weatherCondition",
          type = "weather",
          value = "clear"
        }
     
    Link to comment
    Share on other sites

    • 0
    6 hours ago, john1312143 said:

    Anyone ?

     

    if api.get("/weather").WeatherCondition == "clear"  then

       ---  open blinds

    end

    Link to comment
    Share on other sites

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