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

Yet Another Motion Lights (scene)


10der

Question

Hi!

 

Many clarifications were sought and questions raised on the issue of the "motion light".

So, I have to provide another motion lights scene.

Please find attached the file you requested :)

 

also, this is some samples and comments "how to".

 

Thank you.

Have a nice day. 

 

Oleg.

 

Please login or register to see this code.

 

V2 - 25/11/2018: Added VD support.

VS should have

1)  btnOn = 1, btnOff = 2 buttons

2) lblStatus as label ("ON" / "OFF")

 

V3 - 25/12/2018

1) fixed dimmer level issue

2) now you can use script as timed lighting

Please login or register to see this code.

 

 

 

 

 

 

Please login or register to see this attachment.

Edited by 10der
  • Like 1
  • Thanks 2
Link to comment
Share on other sites

Recommended Posts

  • 0

@10der thx you again, each post I'm reading you're publishing a new code, how many 10ders are in this forum??? 

I'm using the same light scene since many many years but never signed by you so I'll give a try.

big thanks

 

Edited by Tony270570
Link to comment
Share on other sites

  • 0

Hi, is there a way to use this script with Philips Hue VD's?

Seems this script is what I was looking for, hopefully it can work with VD's with 'On'  and 'Off' buttons.

thx for all the work!

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Just now, Rikbast said:

    Hi, is there a way to use this script with Philips Hue VD's?

    idk. :) I haven't such devices. :(

     

    1 minute ago, Rikbast said:

    hopefully it can work with VD's with 'On'  and 'Off' buttons.

    yep.

     

    2 minutes ago, Rikbast said:

    Hi, is there a way to use this script with Philips Hue VD's?

    Seems this script is what I was looking for, hopefully it can work with VD's with 'On'  and 'Off' buttons.

    thx for all the work!

    welcome 

    Link to comment
    Share on other sites

    • 0

    Hi Oleg,

     

    I am trying your script with my VD with on and off button, but I get an error:

     

     

    [DEBUG] 09:16:41: 2018-11-25 09:16:41.728338 [ fatal] Unknown exception: /opt/fibaro/scenes/17.lua:205: attempt to compare number with nil
     

    Line 205 is here:

     

    function getPowerState(dev)
        for i, id in ipairs(dev.powers) do
            local deviceState, deviceLastModification = fibaro:get(id, "value")
            -- if (deviceState == nil) then return 0, 0 end
    205 --->   if (tonumber(deviceState) > 0) then
                return tonumber(deviceState), deviceLastModification
            end
        end
        return 0, 0
    end

     

    Has this to do with the VD?

     

    thx,

    Rik

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Yep! will update today. 

    This script from my archive.actual version a bit different.

    Link to comment
    Share on other sites

    • 0
    On 11/25/2018 at 10:01 AM, 10der said:

    Yep! will update today. 

    This script from my archive.actual version a bit different.

    Ok.Thx. I will wait for the update then.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 21 minutes ago, Rikbast said:

    Ok.Thx. I will wait for the update then.

    already done

    in header now V2

     

    Link to comment
    Share on other sites

    • 0

    Thx! How about 'luxs' and 'minLux'? I want the lights to turn on when motion is detected AND Lux < 50. What should I put in 'luxs'?

    in minLux = 50 I guess?

     

    Ah, 'luxs' is the ID of the lux sensor, right?

    Edited by Rikbast
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @Rikbast Well, maybe you haven't read that properly.

     

    Please login or register to see this image.

    Link to comment
    Share on other sites

    • 0

    OK, I tried, but no Joy.

    I will explain what I did:

     

    25 = motionsensor

    27 = luxsensor

    112 = VD with 1= On and 2 = Off

     

    local lighting = {
        -- in `sensors` you may use any buttons / switch / door sensers
        -- if no `times` = mean  24/7
        -- if `timeout` = mean 60 sec
        -- id `luxs` = mean ignore lux
        Waskeuken = {
            name = "Waskeuken Scene",
            sensors = {25}, -- motion sensor
            luxs = {27}, -- no lux
            minLux = 50,
            powers = {112}, -- lighting
            timeout = 60 * 5, -- by default 5 min
            times = {}
         }
      }

     

     

    There must be something I am doing wrong I am afraid

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Please login or register to see this code.

     

    where 192.168.1.36 IO addr of your HC2

    find 

    "type": "button"

    look  "id":

     

    if buttons id's not 1 & 2 - it doesn't work.

    otherwise, use 

    powers = {112, on = 2, off=3},

     

     

     

     

    Edited by 10der
    Link to comment
    Share on other sites

    • 0

    I am sorry, I can't seem to get it to work with a VD turning on/off with fibaro motion sensor.

     

    local lighting = {
        -- in `sensors` you may use any buttons / switch / door sensers
        -- if no `times` = mean  24/7
        -- if `timeout` = mean 60 sec
        -- id `luxs` = mean ignore lux
        Waskeuken = {
            name = "Waskeuken Scene",
            sensors = {25}, -- motion sensor
            luxs = {27}, -- no lux
            minLux = 50,
            powers = {112,on=1,off=2}, -- lighting
            timeout = 60 * 5, -- by default 5 min
            times = {}
         }
      }
        

    Any other suggestions?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Just now, Rikbast said:

    I am sorry, I can't seem to get it to work with a VD turning on/off with fibaro motion sensor.

     

    local lighting = {
        -- in `sensors` you may use any buttons / switch / door sensers
        -- if no `times` = mean  24/7
        -- if `timeout` = mean 60 sec
        -- id `luxs` = mean ignore lux
        Waskeuken = {
            name = "Waskeuken Scene",
            sensors = {25}, -- motion sensor
            luxs = {27}, -- no lux
            minLux = 50,
            powers = {112,on=1,off=2}, -- lighting
            timeout = 60 * 5, -- by default 5 min
            times = {}
         }
      }
        

    Any other suggestions?

     

    ¯ \ _ (ツ) _ / ¯

     

    like a charm!

     

    Please login or register to see this code.

     

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    This works :)

     

    local lighting = {
        -- in `sensors` you may use any buttons / switch / door sensers
        -- if no `times` = mean  24/7
        -- if `timeout` = mean 60 sec
        -- id `luxs` = mean ignore lux
        Waskeuken = {
            name = "Waskeuken Scene",
            sensors = {25}, -- motion sensor
            luxs = {27}, -- no lux
            minLux = 50,
            powers = {112, on = 1, off = 2}, -- lighting
            timeout = 60 * 5, -- by default 5 min
            --times = {}
         }
      }

     

    However, it seems that the timeout is not working?

    Removing 'times' did the trick

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • times should be correct or absent at all (24/7)

    Edited by 10der
    Link to comment
    Share on other sites

    • 0

    Yes, I removed times

     

    The timeout function is not working. I guess it is because the motionsensor is breached for a defined time (in my case 10 s) and after that returns to 0

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 5 minutes ago, Rikbast said:

    The timeout function is not working. I guess it is because the motionsensor is breached for a defined time (in my case 10 s) and after that returns to 0

    timeout always should works. it's base functionality.

    but... TBH I have some notice here: no motion always calculated by fibaro:getValue(id, "lastBreached")

    so., if device reported me (via HC2) about no motion I take lastBreached value and calculate waiting time.

    so, if your motion sensor setuped as 30sec waiting no motion but you defined timeout 10sec.... I will be waiting 30 + 10 sec... at least

     

    Link to comment
    Share on other sites

    • 0

    If I use minLux AND the timeout function, how does your script work then?

    Will it always check for minLux and thus keep on the lights? Or will the timeout determine when light go out?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • @Rikbast no. min lux works just only for (additional - logic "and") triggering light no checks after.

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