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

Lua sunset frontdoor open / hall light


Guest jrkalf
 Share

Question

Guest jrkalf

This is a basic script that should turn on the entrance hall light when the front door is opened. Only during the sunset period.

This part of the script is a combination of what I've gotten from an user (deraaij) in this forum and part of the standard buildingblocks scene builder.

The reason for posting this is, while I think the buildingblocks editor is nice, it's not matured just yet. The "sensor" bit for seeing whether or not the frontdoor sensor is triggered is in fact not even an option that works. It has to be scripted via lua script only. And the "sunset" script seems to be rather big as well. I don't think it's a super script and it could probably be a lot smaller, so I'm hoping that you guys could help me out to improve the script.

Please login or register to see this code.

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0
Guest deraaij
  • Inquirer
  • Try this:

    Please login or register to see this code.

    Inspired on your code, I doubt it will run other dan during the sunset. I don't have time now but i think you mean after sunset but before sunrise.

    Link to comment
    Share on other sites

    • 0

    I have same thing accomplished with very siple scene (block style). I'm using 3-1 ezmotion sensor and fibaro door/window sensor.

    If the light level is less than 25% and door sensor is breached, the hallway light is turned on at 55% level and turned off after two minutes. works like a charm every time. It can be made a little bit more intelligent by making different conditions according the current light level in the hallway and adjust the turn on level. (If light level is 25-55% then turn on the lights at 70% power etc..)

    Link to comment
    Share on other sites

    • 0
    Guest jrkalf
  • Inquirer
  • Try this:

    Please login or register to see this code.

    Inspired on your code, I doubt it will run other dan during the sunset. I don't have time now but i think you mean after sunset but before sunrise.

    busy busy busy... thanks Mark. I'll try your code options

    The only issue I saw with the original code was that it had set a general "SunsetHour" so it's not specific to the sunset specific time, so if it's 16:59, it'll also be triggered on 16:01. This is from hands-on experience. furthermore, it's not only working during sunsettime. but it works all night to be honest. I've not been home or haven't checked the code during daytime yet. I'll give it a try next weekend.

    Link to comment
    Share on other sites

    • 0

    Hi,

    I have found this a bit of a pain to do just now because the fibaro:getValue(1, "sunriseHour") and fibaro:getValue(1, "sunsetHour") return a string rather than epochs and not a full date string that can convert back.

    The string includes hours and minutes but it does leave a problem.

    If it were an epoch you could just compare the dates using > and less than like this

    Please login or register to see this code.

    BUT THIS WILL NOT WORK.

    Now you could try converting the string back to a full epoch or split the string to the hours and minutes and compare these to the current hout and current minutes but that is verbose and can not be wrapped as a function.

    So I have to admit I have cheated and used a global variable nightTime that is set to 1 as the time passes sunset and set to 0 as the time passes sunrise. This can then be used to check if it is night.

    I don't recommend this as the timers use loops of code and this is very bad for your boxes performance if you had a lot.

    If you want the code PM me but I will not post as we need a proper fix in the API.

    Link to comment
    Share on other sites

    • 0
    Guest jrkalf
  • Inquirer
  • Okay, I've finally found a way to do it. Using RobMac's and Jompa68's magic in this thread:

    Please login or register to see this link.

    After having that proper night time sensor installed I was able to combine it with the sensorcode I already got working with DeRaaij. Now I finally have it working properly. Only during NightTime the hallway will be automagically lit when I open the front door.

    First of all it'll require you to grab the code from the above mentioned topic.

    Don't forget to make a standard "global" variable named NightTime.

    Please login or register to see this code.

    Link to comment
    Share on other sites

    • 0
    Guest Lode
  • Inquirer
  • I've been playing around a little bit and now it works.......

    I only placed the end statement from the first "if" condition at the bottom.

    Can somebody tell me why it's working now and is this the proper way to do it ?

    Please login or register to see this code.

    [ Added: 2013-03-05, 23:25 ]

    Sorry guys, wrong place for my post.

    Please login or register to see this image.

    /emoticons/default_icon_redface.gif" alt=":oops:" />

    Link to comment
    Share on other sites

    • 0
    On 3/5/2013 at 10:18 PM, Lode said:

    I've been playing around a little bit and now it works.......

    I only placed the end statement from the first "if" condition at the bottom.

    Can somebody tell me why it's working now and is this the proper way to do it ?

     

    Please login or register to see this code.

     

     

    [ Added: 2013-03-05, 23:25 ]

    Sorry guys, wrong place for my post.

    Please login or register to see this image.

    /emoticons/default_icon_redface.gif" data-emoticon="" />

     

    I was wondering what id is your light and the door sensor? i am looking for a similar script to work when the door is open and sunset for x duration.

    Link to comment
    Share on other sites

    • 0
    3 hours ago, Al3x said:

    ? i am looking for a similar script to work when the door is open and sunset for x duration.

     

     

    Please login or register to see this code.

    see attachment

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    does anyone have a list of variables that i need to delay as changing the id of light and door sensor will not trigger it when its dark.

    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.

     Share

    ×
    ×
    • Create New...