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

Lights automation [LUA][3.562+]


Question

Posted

Polska wersja:

Please login or register to see this link.

My idea for automation lights in the house. Example of usage...

The enter-room with dimmer. Every move event turn on the lights for 3 minutes and every open door event turn on the lights for 5 minutes. In the last counting minute the lights will dimm down to zero - softly.

Every move or opening the door event will restart counter to 3 or 5 minutes. Manualy turning on the lights will set counter to half hour and then any other event will not be able to set counter for lower time - manual control is a priority.

Summary:

- Automatic switching off lights after counting time.

- Extension of light time based on events (eg move, doors, etc.).

- Without interfering with the manual control.

- Each light has its own timer.

- Dimming light for a defined time.

- Easy access to functions from the scene.

and...

- Everything is based on one single virtual device,

- For presentation timer and counting using slider - one for each device.

- Switching the light in the scenes you can make in the traditional way, or...

- Or simply by setting the slider value (setting the timer) - nothing more!

- You can adjust the slider (timer) in many scenes together.

The whole is fully automated and is simple to implement!

And here's the recipe in a few steps:

1. Define a new virtual device with the following code as Main loop. Change only login and password for your HC2:

Please login or register to see this link.

2. Define the sliders for each device in your home that you want to control by timer. To do this, add a slider in the virtual device with content as below:

Please login or register to see this code.

Fields:

action must be always autoOff;

deviceId id of controlled device;

defaultTime (optionaly) - default timer when the switch is controling manualy;

defaultValue (optionaly) - default maximum dimmer value;

dimmTime (optionaly) - time of dimming on the switching off event;

NEW! wakeTime (optionaly) - wake up period in seconds if devcie is dead.

3. (Optionaly) For presentation on the home screen you can define two elements in that virtual device. One more slider witch id globalSlider and one label id globalLabel with title eg. Turning off:.

That's all.

Just a way to use this functionality in scenes:

Instead of selecting the turn on action, just select the action changes the slider to the virtual device to any value (in seconds). The light will turn on automaticly.

Good luck;)

And one more thing...

Please login or register to see this link.

to have new futures!

Update 1.3:

- added possibilites to set timer (slider) from scenes to any value (even lower than actual) by minused value (eg. -600).

Update 1.2:

- fixed slider values preview,

- added new parameter "wakeTime"

- few others.

Update 1.05:

- possibility to turn off by slider,

- possibility to controll time in any "direction" by main slider

- icons - with animation

Please login or register to see this image.

/emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" />

- bug fixes

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Recommended Posts

  • 0
Posted

Can someone tell me if this VD is working also for lights that are not dimmers? I have some lights on switches(FGS) or Duwi wall plug-in. I tried to put them on sliders but I'm receiving error and it is not functioning. Is there any way to control this kind of lights?(switch)

  • 0
Posted
Can someone tell me if this VD is working also for lights that are not dimmers? I have some lights on switches(FGS) or Duwi wall plug-in. I tried to put them on sliders but I'm receiving error and it is not functioning. Is there any way to control this kind of lights?(switch)

This is a quote from the first page..Hope it helps

Can this be used with a relay switch instead of dimmer? What do i need to change in your setup?

Yes, of course. The code in slider has to look like this:

Please login or register to see this code.

  • 0
Posted

OK ..I had missed that post

Now it's working allright..kind of you

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

  • 0
Posted

you're welcome

Please login or register to see this image.

/emoticons/default_icon_smile.gif" alt=":-)" />

  • 0
Posted

After adding another slider for a dimmer, I deleted "dimmTime": 60

I get this error :

[DEBUG] 23:32:04: Getting list of virtual devices...

[DEBUG] 23:32:04: Status of reqest: 503.

[DEBUG] 23:32:04: Error 0.

[DEBUG] 23:32:17: Getting list of virtual devices...

[DEBUG] 23:32:17: Status of reqest: 200.

[DEBUG] 23:32:17: New device [Dimmer lampa mobil][101] Type [dimmable_light] Value [0].

[DEBUG] 23:32:17: Label 2 / 142.

[ERROR] 23:32:17: line 135: Expected object key string but found T_OBJ_END at character 93

Now not one slider it's working..

Is "dimmTime": xx mandatory to be present for a dimmer?

My globalSlider is not changing timer values.I move it forward/backwards but still it is coming to the same value afterwards..What I'm doing wrong?

  • 0
Posted

Rafal is this code working for Alpha version? I have it on other versions and works beautifully but somehow my testing HC2 which has alpha 02 that is having trouble with it.

  • 0
  • Inquirer
  • Posted
    After adding another slider for a dimmer, I deleted "dimmTime": 60

    I get this error :

    [DEBUG] 23:32:04: Getting list of virtual devices...

    [DEBUG] 23:32:04: Status of reqest: 503.

    [DEBUG] 23:32:04: Error 0.

    [DEBUG] 23:32:17: Getting list of virtual devices...

    [DEBUG] 23:32:17: Status of reqest: 200.

    [DEBUG] 23:32:17: New device [Dimmer lampa mobil][101] Type [dimmable_light] Value [0].

    [DEBUG] 23:32:17: Label 2 / 142.

    [ERROR] 23:32:17: line 135: Expected object key string but found T_OBJ_END at character 93

    Now not one slider it's working..

    Is "dimmTime": xx mandatory to be present for a dimmer?

    My globalSlider is not changing timer values.I move it forward/backwards but still it is coming to the same value afterwards..What I'm doing wrong?

    You have mistake in slider params. Can you post all sliders here?

    • 0
    Posted
    After adding another slider for a dimmer, I deleted "dimmTime": 60

    I get this error :

    [DEBUG] 23:32:04: Getting list of virtual devices...

    [DEBUG] 23:32:04: Status of reqest: 503.

    [DEBUG] 23:32:04: Error 0.

    [DEBUG] 23:32:17: Getting list of virtual devices...

    [DEBUG] 23:32:17: Status of reqest: 200.

    [DEBUG] 23:32:17: New device [Dimmer lampa mobil][101] Type [dimmable_light] Value [0].

    [DEBUG] 23:32:17: Label 2 / 142.

    [ERROR] 23:32:17: line 135: Expected object key string but found T_OBJ_END at character 93

    Now not one slider it's working..

    Is "dimmTime": xx mandatory to be present for a dimmer?

    My globalSlider is not changing timer values.I move it forward/backwards but still it is coming to the same value afterwards..What I'm doing wrong?

    You have mistake in slider params. Can you post all sliders here?

    dimmer1: "{

    "action": "autoOff",

    "deviceId": 101,

    "defaultTime": 360,

    "defaultValue": 40,

    "dimmTime": 30

    } "

    globalLabel : Turning off:

    ID globalLabel

    dimmer2: "{

    "action": "autoOff",

    "deviceId": 9,

    "defaultTime": 120,

    "defaultValue": 40,

    "dimmTime": 2

    } " This is the one that I had tried to cut "dimmTime": 2 out, but being a dimmer probably gave that error.Puting back this parameter the error disappeared

    Fibaro switch1 : {

    "action": "autoOff",

    "deviceId": 8,

    "defaultTime": 60

    } "

    Duwi switch2 : "{

    "action": "autoOff",

    "deviceId": 122,

    "defaultTime": 60

    } "

    globalSlider with ID globalSlider: this is empty(no code in it) and this is not working for me to manually modify time(+ or -) for an ongoing timer

    • 0
  • Inquirer
  • Posted

    Now not one slider it's working..

    Is "dimmTime": xx mandatory to be present for a dimmer?

    No, it's only say how many seconds takes dimming to "zero". If you ommit this parameter, then dimmer will be used as a normal switch.

    My globalSlider is not changing timer values.I move it forward/backwards but still it is coming to the same value afterwards..What I'm doing wrong?

    Global slider is used only for showing - not for control.

    dimmer2: "{

    "action": "autoOff",

    "deviceId": 9,

    "defaultTime": 120,

    "defaultValue": 40,

    "dimmTime": 2

    } "

    This is the one that I had tried to cut "dimmTime": 2 out, but being a dimmer probably gave that error.Puting back this parameter the error disappeared

    In what way you cut this parameter? Did you delete "dimmTime": 2 line?

    • 0
    Posted

    Now not one slider it's working..

    Is "dimmTime": xx mandatory to be present for a dimmer?

    No, it's only say how many seconds takes dimming to "zero". If you ommit this parameter, then dimmer will be used as a normal switch.

    My globalSlider is not changing timer values.I move it forward/backwards but still it is coming to the same value afterwards..What I'm doing wrong?

    Global slider is used only for showing - not for control.

    dimmer2: "{

    "action": "autoOff",

    "deviceId": 9,

    "defaultTime": 120,

    "defaultValue": 40,

    "dimmTime": 2

    } "

    This is the one that I had tried to cut "dimmTime": 2 out, but being a dimmer probably gave that error.Puting back this parameter the error disappeared

    In what way you cut this parameter? Did you delete "dimmTime": 2 line?

    Yes I deleted "dimmTime": 2 line and got that error.. put the line back and .. no error

    I think it has to do with the comma after the last line "defaultValue": 40, maybe it has to be deleted(comma), when this remains the last line of code

    About globalSlider, I saw some posts :

    "Update 1.05:

    - possibility to controll time in any "direction" by main slider "

    martinpreiss said :

    " rafal.m, first of all great script! I have few bugs:

    1] if i move slider other then global, it will jump right back on time it was counting from. So if there is 3450 sec i move slider to 45 then it will jump right back to 3449. If I do that in Global slider, it works. In individual sliders it doesn't"

    You said:"That is not without reason. It is protection for setting time from scenes to lower value than actual counter. Example: if you have "move detect" scene whitch setting counter to 300 sec, you don't want situation, when that move decreses time after you switch lights manualy and counter starts from 3600 sec.

    Right now it's not possible to check if the slider was changed from scene or manualy by user, so protection working all the time."..

    But I understand from martinpreiss that if he moves globalSlider it works(modify + or - the time of the slider) ??

    • 0
  • Inquirer
  • Posted

    Yes I deleted "dimmTime": 2 line and got that error.. put the line back and .. no error

    I think it has to do with the comma after the last line "defaultValue": 40, maybe it has to be deleted(comma), when this remains the last line of code

    You have to delete last comma.

    About globalSlider, I saw some posts :

    "Update 1.05:

    - possibility to controll time in any "direction" by main slider "

    martinpreiss said :

    " rafal.m, first of all great script! I have few bugs:

    1] if i move slider other then global, it will jump right back on time it was counting from. So if there is 3450 sec i move slider to 45 then it will jump right back to 3449. If I do that in Global slider, it works. In individual sliders it doesn't"

    You said:"That is not without reason. It is protection for setting time from scenes to lower value than actual counter. Example: if you have "move detect" scene whitch setting counter to 300 sec, you don't want situation, when that move decreses time after you switch lights manualy and counter starts from 3600 sec.

    Right now it's not possible to check if the slider was changed from scene or manualy by user, so protection working all the time."..

    But I understand from martinpreiss that if he moves globalSlider it works(modify + or - the time of the slider) ??

    That was in old version. You have to remember that sliders working good only for settings time from scenes. Manual control of sliders is dificulte becouse now value has dynamic content. It's hard to explain, but in summary script is not for manual control.

    • 0
    Posted

    The reset counter is nog working for me. If there is still movement in the room the light turns of and turns on again.

    Also the default time (3600sec) is not working when i use the button.

    Am i doing something wrong? Do i need the GlobalSlider?

    Virtual device:

    {

    "action": "autoOff",

    "deviceId": 22,

    "defaultTime": 3600,

    "defaultValue": 40,

    "dimmTime": 5

    }

    Please login or register to see this image.

    [ Added: 2014-10-06, 12:45 ]

    I created the GlobalSlider but it's still not working :-(

    [ Added: 2014-10-17, 15:28 ]

    Is there someone who can help me? :(

    • 0
    Posted

    HI.

    The link doesn't work anymore.

    Please login or register to see this image.

    /emoticons/default_icon_eek.gif" alt=":shock:" />

    • 0
    Posted

    Has someone tried Rafals"Lights automation" with 4.***?

    Its a big part of my home.

    • 0
    Posted

    It was a big part of my home...

    Now it dosen't seem to work anymore, don't know why yet but i'll post some debug when i have energy for dealing with this.

    [DEBUG] 21:09:56: Getting list of virtual devices...

    [DEBUG] 21:09:56: Status of reqest: 200.

    [DEBUG] 21:09:56: New device [strålkastare][144] Type [com.fibaro.binarySwitch] Value [0].

    [DEBUG] 21:09:56: New device [Fasadbelysning][34] Type [com.fibaro.binarySwitch] Value [0].

    [DEBUG] 21:09:56: Label 3 / 246.

    [DEBUG] 21:09:56: Global slider 4 / 246.

    [DEBUG] 21:10:14: Device [34][Manual]: Value [1][1 s.]; Slider [35999][18 s.];

    [DEBUG] 21:10:15: Device [34][Manual]: Value [1][2 s.]; Slider [35998][19 s.];

    [DEBUG] 21:10:17: Device [34][Manual]: Value [1][4 s.]; Slider [35997][21 s.];

    [DEBUG] 21:10:18: Device [34][Manual]: Value [1][5 s.]; Slider [35996][22 s.];

    I have removed, imorted and created new VD several times but it still doesn't function.

    The problem is that the VD doesn't seem to accept slider values, if i turn a device on manually it counts down and turn the device off.

    But if a set a slider value from a scen it sets the value (but not on the slider) and then Counts down 1 sec en restart.

    I can't get my head around this, can anyone confirm that it works in 4.031?

    • 0
    Posted
    It was a big part of my home...

    Now it dosen't seem to work anymore, don't know why yet but i'll post some debug when i have energy for dealing with this.

    [DEBUG] 21:09:56: Getting list of virtual devices...

    [DEBUG] 21:09:56: Status of reqest: 200.

    [DEBUG] 21:09:56: New device [strålkastare][144] Type [com.fibaro.binarySwitch] Value [0].

    [DEBUG] 21:09:56: New device [Fasadbelysning][34] Type [com.fibaro.binarySwitch] Value [0].

    [DEBUG] 21:09:56: Label 3 / 246.

    [DEBUG] 21:09:56: Global slider 4 / 246.

    [DEBUG] 21:10:14: Device [34][Manual]: Value [1][1 s.]; Slider [35999][18 s.];

    [DEBUG] 21:10:15: Device [34][Manual]: Value [1][2 s.]; Slider [35998][19 s.];

    [DEBUG] 21:10:17: Device [34][Manual]: Value [1][4 s.]; Slider [35997][21 s.];

    [DEBUG] 21:10:18: Device [34][Manual]: Value [1][5 s.]; Slider [35996][22 s.];

    I have removed, imorted and created new VD several times but it still doesn't function.

    The problem is that the VD doesn't seem to accept slider values, if i turn a device on manually it counts down and turn the device off.

    But if a set a slider value from a scen it sets the value (but not on the slider) and then Counts down 1 sec en restart.

    I can't get my head around this, can anyone confirm that it works in 4.031?

    +1, same problem here...

    • 0
    Posted

    This is a change to how slider returns.. Have a look a developer.fibaro.com for New syntax. Away from home so can't check. Also answer is in forum somewhere in a thread. One of the alpha or beta threads talking about Vd not working.

    • 0
    Posted

    I just had a brief look - could not find it. Will have another look later...

    [ Added: 2015-01-15, 22:14 ]

    This is a bit modified - it does not solve everything, on the other hand, not all works in the original either... Have a go and feel free to comment

    Please login or register to see this image.

    /emoticons/default_icon_wink.gif" alt=";-)" />

    Please login or register to see this code.

    • 0
    Posted

    For it to work properly with dimmers you have to update deviceType from "dimmable_light" to "com.fibaro.multilevelSwitch" in the code.

    This is due to a change in 4.x

    Please login or register to see this code.

    • 0
  • Inquirer
  • Posted

    Please login or register to see this link.

     

    Thanks

    Please login or register to see this link.

     and

    Please login or register to see this link.

    !

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