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)


Question

Posted (edited)

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

Recommended Posts

  • 0
Posted (edited)

@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
  • 0
  • Inquirer
  • Posted

    @Tony270570 welcome!

    • 0
    Posted

    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!

    • 0
  • Inquirer
  • Posted
    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 

    • 0
    Posted

    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.

    • 0
  • Inquirer
  • Posted

    Yep! will update today. 

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

    • 0
    Posted
    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.

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

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

    already done

    in header now V2

     

    • 0
    Posted (edited)

    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
    • 0
  • Inquirer
  • Posted

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

     

    Please login or register to see this image.

    • 0
    Posted

    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

    • 0
  • Inquirer
  • Posted (edited)

    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
    • 0
    Posted

    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?

    • 0
  • Inquirer
  • Posted
    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.

    • 0
    Posted

    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

    • 0
  • Inquirer
  • Posted (edited)

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

    Edited by 10der
    • 0
    Posted

    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

    • 0
  • Inquirer
  • Posted
    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

     

    • 0
    Posted

    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?

    • 0
  • Inquirer
  • Posted

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

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