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
1 minute ago, 10der said:

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

Ok, my lights (VD) won't go out after the timeout. On button id = 1, Off button id =2.

What could be causing this?

  • 0
  • Inquirer
  • Posted (edited)
    Quote

    What could be causing this?

    No.

    cuz you":unattended".

    I said before 2 times + send to you VD sample.

     

     

    you miss providing current status. 

    script trying to get current status from VD - but you return nothing.

    1) please add to VD lblStatus with ON / OFF string values

    2) update your main VD loop with the keeping actual status of VD

    3) for the future - please use debugMode = true, for understanding what doing

     

    thank you!

    Edited by 10der
    • 0
    Posted
    19 hours ago, 10der said:

    No.

    cuz you":unattended".

    I said before 2 times + send to you VD sample.

    Sorry! I missed the VD sample, now I got.  It works!

    Forgive me, I am coming from Domoticz, so I need to get used to the Fibaro way

     

    19 hours ago, 10der said:

     

    you miss providing current status. 

    script trying to get current status from VD - but you return nothing.

    1) please add to VD lblStatus with ON / OFF string values

    2) update your main VD loop with the keeping actual status of VD

    3) for the future - please use debugMode = true, for understanding what doing

     

    thank you!

    Yes, I see now how it works. I am learning day by day now. Thank you for all the hard coding work.

    I will test further now and will let you now the outcome.

    • 0
  • Inquirer
  • Posted

    @Rikbast Welcome, Sir!

    • 0
    Posted

    Now I am thinking . Suppose you have VD with combined ON/OFF button, so no separate ON and OFF button. How to cope with such a VD in your script?

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

    combined ON/OFF button, so no separate ON and OFF button.

    is not clear for me, sorry.

    • 0
    Posted
    38 minutes ago, 10der said:

    is not clear for me, sorry.

    I mean toggle button On/Off

    • 0
  • Inquirer
  • Posted (edited)
    3 minutes ago, Rikbast said:

    I mean toggle button On/Off

    I do not care about the current button state!

    you should simply keep lblStatus state. I should always know status of lighting 

    Please login or register to see this attachment.

    Edited by 10der
    • 0
    Posted

    It works nice now! thx

    Can I use also a rollershutter with 'powers' ? And I was wondering if it's possible to do a logical check for a light to be on or off and then trigger a light scene (VD) together with a motionsensor breach?

     

    Sorry if I have a lot of questions, but I need to rewrite a lot of scripts from domoticz.

    • 0
  • Inquirer
  • Posted
    1 minute ago, Rikbast said:

    together with a motionsensor breach?

    1

     

    together - mean with XXX

    please use comma and Ids 

    Please login or register to see this code.

    • 0
    Posted

    Yes, I want to check for a light to be On or Off and check the motionsensor.

    For instance, A certain light is already On and the motion is detected, nothing should happen. However when light is Off and motion is detected light should go On.

     

    It is like this:

     

    if (Lamp == '0') and (Motionsensor > 0 ) and (Rollershutter1 ~= '99') and (Rollershutter2 ~= '99') then

     

    "Start a lightscene (VD)"

     

    End

    • 0
  • Inquirer
  • Posted
    1 hour ago, Rikbast said:

    [Skiped]

    if (Lamp == '0') and (Motionsensor > 0 ) and (Rollershutter1 ~= '99') and (Rollershutter2 ~= '99') then

     

    so. you want additional checks.

     

    not sure (cuz I develop it for other things) play with 

    Please login or register to see this code.

     

    • 0
    Posted

    Can the script use global variable as sensor? 

    I would like the status of the heating for switching on fan

    • 0
    Posted

    Hello 10der, find your script-idea smart and trying to use.

    Simple on/off working fine. Have trouble by configuring a dimmer for the hall. The lights must going on 06:00..00:00 with level 99 and for the night (00:01..05:59) with level 15.
    This is my setup for this part:

     

    Flur_KG = {
            name = "Flur_KG",
            sensors = {185,1186,1194,1193},   
            powers = {438}, 
            timeout = 60 * 2,        
            times = { ["06:00..00:00"] = {level = 99},
                       ["00:01..05:59"] = {level = 15}  }  
        },

     

    On most times the light turns fast on and turns immediately off. From time to time (i don't know why) lights gos on correctly.

    The debug on the "issue" is:

    Please login or register to see this image.

    /monthly_2019_01/image.png.a7cdddc349c09c07bb934c0348692d32.png" alt="image.png.a7cdddc349c09c07bb934c0348692d32.png" />          
       
     I'm reading your code, but can't find the reason for this...
     

    • 0
  • Inquirer
  • Posted
    On 11/28/2018 at 1:28 PM, 10der said:

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

    sorry, double fail.

    1) Yes it's true!

    2) I was fixed dimming at December :) sclerencephalia :)

    • 0
    Posted

    Hello 10der,

    thank you for your very fast response.

    Integrate updated code - same result.
     

    The lights turns on and instantly off.
    Debug is 

    Please login or register to see this image.

    /monthly_2019_01/image.png.1a7342d763b26d4940b3e2106a8f65bd.png" alt="image.png.1a7342d763b26d4940b3e2106a8f65bd.png" />

    • 0
  • Inquirer
  • Posted

    @Speedo67 ok

    trying to reproduce

     

    define

    Please login or register to see this image.

     

    debug

    bcygTLmrxS.png

     

     

     

    your oGcgUrJmmf.png

    said about your device not send back to HC2 own current status and script means what smd turned off the device.

     

    AFAIK some (China) device sometimes not back own state. for example, it's China old TKB dimmer 

     

    Please login or register to see this link.

     

    now it is OFF. but Fibaro UI show me as 

    BhtYBD2hrJ.png

     

    more than

    chuXEq0fsG.png

     

    answer

    cuQHNw0Yw4.png

     

    but

    J6KsklDNET.png

     

    cool isn't it?

     

     

     

    • 0
    Posted

    Hello 10der,

    first i will thank you very much for your quick and extensive response.

    No, it is not chineese-ware it is Fibaro dimmer FGD211 with bypass.

     

    But i agree with you, it is not your script, it is my (hardware)setup. Test your script with FGD212  - works fine.
    Now i will a little playing around to fix this "issue". For the first i have adjusted parameters FGD211 accordingly FGD212 - this isn't help.
    One additional effect is, breach the sensor, light is turning quick on and instantly off. If i breach the sensor short time after, the light goes as disired on and by timeout off.

    So i  think the "issue" is related with the LastModificationTime...

    I will give a response, if i have news. For now i must make money...

    • Like 1
    • 0
    Posted

    Hello together,

    first off all HUGE THANKS TOO @10der, works brilliant.

    Now I am optimizing to my needs.

    Before I set the updated scene online I have a question regarding Dimming level function.
    I know how to set by for example --> times = {["00:01..06:00"] = {level = 45} but how does it work with in this script when i define as powers "Double Switch (non dimable)" and "Dimm Relay" together?
     

    Will it work, that the Double Switch goes on (1) and Dimmer will set to 45%?
     

    ###################################################################

    local lighting = {
        -- in `sensors` you may use any buttons / switches / door sensors
        -- if no `times` = mean  24/7
        -- if no `timeout` = mean 60 sec
        -- id no `luxs` = mean ignore lux
        Diele_EG = {
            name = "Diele EG Motion lighting",
            sensors = {227},    -- motion sensor
            luxs = {229},           -- no lux if empty, ID229 lux Motion Sensor Diele
            minLux = 20,          -- min lux, works only if lux id's defined - rule = no money no honney
            powers = {98,97,131},
                                            -- ID98 des Double Switch 1 for Panel //
                                            -- ID97 des Double Switch 2 for Spot Gaderobe
                                            -- ID131 des DIM Relay Deckenspot
           timeout = 60 * 1,    -- by default 1 min
           times = {["00:01..06:00"] = {level = 45},
                          ["06:01..08:00"] = {level = 75},
                          ["08:00..$Sunset-20"] = {level = 45},
                          ["$Sunset-19..00..00"] = {level = 75},
                         }
           }

    ###################################################################

     

    Best Regards

     

    PS: I am not at home, so I cannot test it yet.

    • 0
  • Inquirer
  • Posted (edited)
    35 minutes ago, master_jo1 said:

    Will it work, that the Double Switch goes on (1) and Dimmer will set to 45%?

    long-short:

     

    turning on method always check type of a device, if it's dimmable device - method pass value as-is (45) if it's a not dimmable  device - just re-translate your value by rule if value > 0 turnOn else turnOff  

    Edited by 10der
    • Like 1

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