About This File
Very Smart Lights™ v1.4.3
Hello everyone!
I am so excited! Very Smart Lights™ scene just get smarter!!! Thanks to all of you for valuable feedback and requests! We are listening and acting! So here it is, completely rewritten, smarter, better scene to control your home lighting!
NEW UPDATE v1.4.3 (09 Apr 2019)
This update brings support for Philips HUE AIO VD v3.0 standalone! I have updated instructions for setting up HUE AIO VD in scene code and also I have optimized a bit code. This scene can still work with HUE VD old versions but I humbly recommend upgrading HUE VD to the latest version.
UPDATE HISTORY
1.4.2 (11 Jan 18)
Two updates in one day! In v1.4.2 corrected code for HUE plugin lights. Problem was that scene was turning on HUE plugin lights at brightness 1 even brightness was set to 0 to keep them Off. Thanks to @shingoo for pointing out this bug!
1.4.1 (11 Jan18) - Corrected bug that was causing scene to stop working if RGBW lights are controlled and useIndoorLights and indoorLightsDim where set to Yes. Many thanks to @AndrewB82 for reporting this bug!
1.4.0 (20. Jan 17) -
What is new:
- Darkness is not used anymore for turning On lights and dim low levels. Only TimeOfDay is now used for that purpose.
-
Added support for different types of Philips HUE light VD. Scene now supports HUE color ambience, HUE white ambience and HUE white dimmable only bulbs and VDs. Also added support for customized HUE VD. Support for HUE plugin remain same. It is now possible to mix different types of HUE VD since now you have to define VD type for each HUE light. Ambient color settings can now be stored also for White ambience bulbs. Also added default color setting for this bulbs!
-
Added two new global variables for Cooking and for Mealtime that can be used to define different brightness levels and to keep lights On as long as this variables are set to Yes if added to extraGlobalName.
-
Corrected dimming of RGBW lights when useRGBWcolor is set to Yes. Also RGBW lights will now turn on when dim low is set on defined settings.
-
Corrected duration timer compensation with PIRwindowTime. Now is properly calculated and warning displayed if duration setting is lower than PIRwindowTime. Now lights will always turn on for the duration of motion sensor breach time.
-
Corrected scene behavior when PresentState and SleepState are changed. When PresentState is changed to Home or Holiday scene will turn on lights when motion is detected or dim low if set for that part of day. Same is when SleepState change from Sleep to Awake. When PresentState is set to Holiday scene can be controlled by global variable triggers
-
Global variable SleepState added to scene header global triggers so now scene will turn Off or dim low lights when SleepState is set to Sleep or turn on or dim low lights when set to Awake! It is not needed any more to manually run VLS scene to do that!
-
Completely rewritten code for turning On/Off lights and added error handling so now you will know if there is some mistake in settings for quick correction. If you don't use special condition for HolidayLights then you don't need to setup flags anymore. If any of special conditions is not used like IndoorLightsDim and use is set to No then you don't even need to add this global variable to variable panel!
-
Added debugging for lights handling so if there is any problems you can turn lightdebug to true and see how each light is controlled and what brightness setting is used for each defined light.
-
Refined other debugging messages and added more colors for easier reading and fault finding.
1.3.5 (09. Jan 17) - Corrected that scene turn off switch lights if user set valSWT to 0. Corrected that scene turn off RGBW lights if program is running or color is enabled if dimRGB is set to 0. Added ProjectorState global variable that can be used to additionally setup lighting for movie time with projector. So now you can have two different setup to watch movies! Don't forget to put CinemaState and ProjectorState to extraGlobalName to keep lights at predefined values!
1.3.4 (09. Jan 17) - resolved bug for keepDimSleep setting that logic was reversed. Now if set to true will keep lights dimmed and false will turn them off when SleepState is set to sleep. Rectified situation when scene not turning lights on at all if not using light sensors. Corrected dimOff logic to properly dim or turn off lights depending on settings. Cleaned code of some other bugs found during testing. Also removed ™ and © symbols from code because some users reported trouble with these on Windows 10.
1.3.3 (06. Jan 17) - resolved bug that was preventing extra timer using jompa68 Alarm clock from proper functioning. Extended dimOff function so now lights can be dimmed low during all day and also all night regardless of SleepState depending on your settings. Corrected scene behavior when sleepingName and PresentState global variables value changes and added debugging messages.
1.3.2 (30. Dec 16) - Added support for latest version of jompa68 Alarm clock 3.0.0. Added possibility to define two different dimming levels for Evening and Night time if there is no movement in room and lights are set to dim instead switch off. Corrected bug for turning on RGBW lights if program and color set to No. Added some basic checking of user settings if HolidayLights flag, Brightness and dimOff values are missing. Corrected how scene handles ambilight settings. dim and off ambilight changed to one setting dimOffAmbilight and it must be set to Yes to use settings. keepAmbilight is just setting if you want to keep color when motion detected or use defalut colors. Even if you do not keep colors while in room they will still revert to color when no movement detected.
1.3.1 (25. Dec 16)- Corrected usage of dimAmbilight and offAmbilight so that only color and saturation is remembered while brightness is set by scene setting corrected Alarm clock timer to check if it is turned Off to not keep lights on.
1.3 (First public release) - Added ambilight selection so that scene remembers previous status of the HUE lamps to dim back when no motion in the room, or even leave settings after turning them off. It is also possible to select if HUE lamps will raise brightness in ambilight colors or to default settings when there is motion in the room. Now every lamp can be set to different light level for every used situation like (hoilday lights, guests, cinema, etc.) and for every part of the day.
SCENE DESCRIPTION
You need one copy of this scene for each room or space. One room can have two scenes if needed to control two different groups of lights, but one scene is not supposed to control lighting in more than one room! Here is short description (new 09. Jan 17, thanks to @clowg):
How it works:
This scene uses Darkness and TimeOfDay global variables to change brightness of the lights when there is motion in the room and same times to dim lights when there is no motion if that option is turned on. TimeOfDay can have four different values Morning, Day, Evening and Night. Darkness can have two values Light and Dark. They both change values according to sunrise and sunset times and are very important for proper functioning of VSL scene. I recommend installing Main scene for time based events control with Sunrise & Sunset virtual device to ensure proper handling of this two important global variables. More info about Main scene you can find on provided link.
You do not need to change the LightStatus, nor times when Morning, Day, Evening and Night starts. Once these values are set, the Main scene will move those times according to the sunrise and sunset times. Day duration is changing throughout the whole year and the Main scene and Sunrise & Sunset VD will make sure that everything else is following these times!
SCENE SPECIFICATION
SCENE IS CONTROLLED BY ANY NUMBER OF MOTION, LIGHT AND DOOR/WINDOW SENSORS AND GLOBAL VARIABLES
- With this scene lights can be controlled by any number of motion sensors, light sensors, door/window sensors and global variables that can be mirror of the motion sensors from other alarm systems or used to mimic lights while you enjoy your vacation.
- Light level (lux) is calculated if used more than one light sensor.
- If lights are turned On but lux level reaches turning Off threshold then lights will turn off no matter what other condition keeps them on (motion, extra devices or globals, extra timers).
LIGHT DEVICES THAT CAN BE CONTROLLED
Tested and can control any number and any combination of this types of light control devices:
1) Philips HUE virtual device - pls check --> Philips HUE Color & White ambience VD
2) Philips HUE plugin
3) FIBARO Dimmer 2
4) FIBARO single/double switch
5) FIBARO RGBW module including programs, color RGB/RGBW and white only
6) FIBARO smart plug
Not tested but can possibly control devices from other manufacturers. (need your feedback!)
For FIBARO RGBW module you can define seven different programs for each day of the week and time of day when you want program to be run.
LIGHT BRIGHTNESS AND DURATION CONTROL
Light brightness for each individual light can be set and duration (ONLY ONE FOR ALL LIGHTS!) can be defined by these conditions:
1) Guests time
2) Cooking time
3) Mealtime
4) Projector movie time (NEW v1.3.5)
5) Cinema time
6) Holiday time
7) Indoor lights time
? Sleep/Awake
9) Time of day
All this states can be fully configured or just switched off and use only Time of day condition.
EXTRA DEVICE AND/OR GLOBAL VARIABLE CONDITION CHECK
Extra device value or/and power consumption and global variable check gives you ability to disable switching off lights for as long as status of device and/or global variable meets defined value. For example:
1) If working table smart plug consumption is greater than 10W then keep lights on
2) if bathroom door is closed then keep lights on
4) if TV is on can be checked by global variable status or smart plug then keep lights in living room on and dimmed.
5) if outside is day but overcast and/or raining then set global variable and keep lights in kitchen always on
EXTRA TIMERS
User can define extra timer that will keep lights on for predefined time. For example you can keep light on for defined time eg. 1 hour after alarm clock wakes you up. Control is done by using alarm clock global variable setting.
TIMER TO TURN ON ANY DEVICE/SCENE/CHANGE VALUE TO GLOBAL VARIABLE AFTER PREDEFINED TIME
Scene has timer that can start up any number of devices and/or scenes and/or change global variables value if it is running longer than predefined time. For example if you stay longer in bathroom so scene is running longer than 5 minutes then it can start up extraction fan and also start scene that will stop fan after predefined time and also after 10 minutes in bathroom change global variable value which will in return send push notification to your loved one that you are currently really busy
INSTALLATION GUIDE
Please check this video made by @MarcoTorino71:
Since I did a lot of comments and instructions in scene itself what and how to setup I will just use some examples here to give some more information. But first of all there are some global variables that must be added to global variable panel before scene can run correctly so here they are:
GLOBAL VARIABLES DEFINITION
All following global variables are predefined global variables to be added in lower part of variable panel! Possible values can be set in your language and then mapped to values in english used in scene code!
1) TimeOfDay - possible values "Morning", "Day", "Evening", "Night". This global variable value is controlled by Main scene for time based events control. TimeOfDay condition will be override by all conditions bellow. If useTimeOfDay is set to "No" then you need to setup Awake brightness settings.
2) PresentState - possible values "Home", "Away", "Holiday". This global variable value is controlled on my HC2 with scenes that are run when we leave or come back home. Those scenes are actually responsible for more actions than just change value of this global variable but about them some other time. You need to take care to change value of this global variable.
3) LightState - possible values "Auto" and "Manual". This variable value is set by virtual device. If value is set to Auto then Very Smart Lights™ scenes are enabled and will control lighting as needed. If value is set to Manual then Very Smart Light™ scenes will be disabled and light can be controlled old fashion way with wall switches only. You need to make simple VD to change value of this variable.
4) GuestState - possible values "Yes" and "No". Value is changed either with VD or scene that is run when guests arrive. If set to Yes then lights will be set to predefined brightness level and can also be kept On during guests visit. This condition also has highest priority and will override all other conditions if set yo Yes.
5) CookingState - possible values "Yes" and "No". Value is changed either with VD or scene that is run when you are busy in the kitchen. When set to Yes it will override other conditions bellow.
6) MealState - possible values "Yes" and "No". Value is changed either with VD or scene that is run when you are having launch or dinner. When set to Yes it will override other conditions bellow.
7) ProjectorState - possible values "Yes" and "No". Variable value is set by VD or scene that controls movie projector and other devices connected. As above variable if ProjectorState is set to Yes then scene will adjust light brightness to desirable levels. When set to Yes it will override other conditions bellow.
? CinemaState - possible values "Yes" and "No". Variable value is set by VD or scene that controls TV and other devices connected to TV. As above variables if CinemaState is set to Yes then scene will adjust light brightness to desirable levels. When set to Yes it will override other conditions bellow.
9) HolidayLights - possible values "On" and "Off". Variable value is set by VD Holiday Lights v1.0. If value is set to On then lights will be dimmed to predefined brightness. Also scene will stop control selected lights which holidayFlag is set to 1 so that they can be controlled by some other scene or VD like HUE lamps changing colors. When set to Yes it will override other conditions bellow. If it is set to Off then other conditions will apply and scene will take over control of all lights even holidayFlag is set to 1. With all those Christmas lights blinking in color we don't want to spoil that atmosphere with main light turned on to maximum brightness so you can set special brightness level of dimmer lights and select not to turn on some of the switch lights, also you can choose some of the HUE lamps or any other lamp not to be controlled any more with Very Smart Light™ scene but use another scene to control their color or brightness change or even some of the nice mobile applications! Here you can download Holiday Lights VD that will change value of this global variable and turn on/off holiday (Christmas) lights: [VD] Holiday Lights [Christmas Lights],
10) IndoorLightsDim - possible values "Yes" and "No". This variable can be set by VD or scene. I used it to dim indoor lights during summer time to keep insects that are provoked by lights to enter our house through open windows and doors. So if set to Yes then lights in the house will stay dimmed to sleep brightness levels. This condition will be override by all conditions above.
11) SleepState - possible values "Awake" and "Sleep" . This global variable value is controlled on my HC2 with two scenes. One is "Good morning" and is activated either by Alarm clock ACWUT (AlarmClock + WakeUpTime) - version 3.0.0 made by @jompa68 or manually with swipe or dimmer switch. Other one is "Good night" scene that is activated either by swipe or dimmer switch. This global is used only to change light brightness during sleep time. If you want to disable lights turning on then see bellow global variable SleepXxxxx!
12) SleepXxxxx - possible values "Yes" and "No". In name of this variable use room name instead of Xxxxx. You can define this variable for bedrooms and living room if you use it sometimes as bedroom like SleepLiving, SleepMaster, SleepRoom1, etc. You need to add name of this global variable to local variable sleepingName. In comparison to "SleepState" which puts to sleep entire house or apartment this one is used to put to sleep only one room. So it can be used to turn living room into bedroom, or to disable lights in children rooms so they can go sleep earlier and we don't have to put entire house to sleep. If value is set to "Yes" then it disables smart light and immediately turns lights of. If set to "No" enables smart light and also turn on lights immediately if there was motion in the room. In our children bedrooms I setup dimmer 2 switch 2 to start scene on 1 click which then press button on VD to change state of this variable from "No" to "Yes" and vice versa so they can switch off lighting themselves. Put also this global variable under the scene header section %% globals! If you don't need it then just leave empty quotes.Value of this global variables can be changed to Yes or Sleep by simple VD with one label that will show status and one button to change status:
All following global variables are global variables to be added in upper part of variable panel!
12) Darkness - global variable (upper part of variable panel) with possible values 0 for day time (Light) and 1 for night time (Dark). Value is changed at adjusted time for sunrise and sunset time. This variable is also controlled by Main scene for time based events control
Now when all needed global variables are defined in variable panel it is time to copy paste code to new scene and configure it. So let see through examples how to set this scene to control our lighting.
Here is part of code where you can setup global variables names and make mapping of your values with corresponding values in code. Also you can define which of the extra conditions for light brightness levels you like to use by setting use variable either to Yes to use condition or No to not use.
Using this above global variables for different conditions allow us to automate change of lights status and it happens automatically without needing us to intervene. That's what home automation is about! Bellow is example of global variables setup for living room that can be also transformed to bed room:
-- GLOBAL VARIABLES --------------------------------------------------------- -- enter names and value mapping of your global variables or leave as it is -- and add to variables panel -- get the table of device & scene IDs from global variable HomeTable. If -- then uncomment bellow line else leave it as it is! -- local jT = json.decode(fibaro:getGlobalValue("HomeTable")); -- "PresentState" is predefined global value that determines if you are at home -- away or on holidays. This variable value is set by other scene or VD. -- Enter name of your global variable between "" or leave as it is local presentState = "PresentState"; -- Enter corresponding values that you use for presence local presentStateMapping = {Home="Home", Away="Away", Holiday="Holiday"}; -- "SleepState" is predefined global variable that determines if you are -- sleeping or are awake. This variable value is set by other scene or VD. local sleepState = "SleepState"; local sleepStateMapping = {Sleep="Sleep", Awake="Awake"}; -- if you donot want to use SleepState then set following variable to "No" -- otherwise to "Yes". If set to "No" and not using sleepState then make -- sure that you put useTimeOfDay to "Yes" otherwise lights will always -- turn to Awake level!! local useSleepState = "Yes"; -- "sleepingName" predefined global variable with possible values: "Yes", -- "No" but in comparison to "SleepState" which puts to sleep entire house -- or apartment this one is used to put to sleep only one room. So it can be -- used to turn living room into bedroom, or to disable lights in children -- rooms so they can go sleep earlier and we donot have to put entire house -- to sleep. If value is set to "Yes" disables smart light, "No" enables smart -- light. If you donot use it then just leave "" empty. In our children -- bedrooms I setup dimmer 2 switch 2 to start scene on 1 click which then -- press button on VD to change state of this variable from "No" to "Yes" and -- vice versa so they can switch off lighting themselves. When this variable -- value change from "Yes" to "No" this scene will turn off lights and will -- not turn on lights on movement. Put also this global variable under scene -- header section %% globals! local sleepingName = ""; local sleepingMapping = {Yes="Yes", No="No"}; -- "LightState" is predefined global variable with possible values: "Auto", -- "Manual". If set to "Auto" then smart lights are enabled if set to "Manual" -- then lights have to be turned On/Off manually because all very smart light -- scenes are disabled! Value is changed with VD. local lightState = "LightState"; local lightStateMapping = {Auto="Auto", Manual="Manual"}; -- "IndoorLightsDim" is predefined global variable with possible values: -- "Yes", "No". If set to "Yes" then lights will be dimmed to Sleep level -- regardless of any other settings (Guest, Awake, Cinema), "No" will enable -- other dimming levels. We use this during summer to dim lights in house not -- to attract insects since windows and doors are opened. Value is changed -- with VD. local indoorLightsDim = "IndoorLightsDim"; local indoorLightsMapping = {Yes="Yes", No="No"} -- if you do not want to use indorLigtsDim then set following variable to "No" -- otherwise to "Yes" local useIndoorLights = "No"; -- "CinemaState" is predefined global variable with possible values: "Yes", -- "No". If set to "Yes" lights will dim to predefined levels by dimDIMCinema -- & dimVDCinema and status can be changed by VD that controls TV. local cinemaState = "CinemaState"; local cinemaStateMapping = {Yes="Yes", No="No"}; -- if you do not want to use cinemaState then set following variable to "No" -- otherwise to "Yes" local useCinemaState = "No"; -- "ProjectorState" is predefined global variable with possible values: "Yes", -- "No". If set to "Yes" lights will dim to predefined levels by dimDIMprojector -- & dimVDprojector and status can be changed by VD that controls projector local projectorState = "ProjectorState"; local projectorStateMapping = {Yes="Yes", No="No"}; -- if you do not want to use cinemaState then set following variable to "No" -- otherwise to "Yes" local useProjectorState = "No"; -- "CookingState" is predefined global variable with possible values: "Yes", -- "No". If set to "Yes" lights will dim to predefined levels by dimDIMcooking -- & dimVDcooking and status can be changed by VD that controls cooking local cookingState = "CookingState"; local cookingStateMapping = {Yes="Yes", No="No"}; -- if you do not want to use cookingState then set following variable to "No" -- otherwise to "Yes" local useCookingState = "No"; -- "MealState" is predefined global variable with possible values: "Yes", -- "No". If set to "Yes" lights will dim to predefined levels by dimDIMMeal -- & dimVDMeal and status can be changed by VD that controls mealtime local mealState = "MealState"; local mealStateMapping = {Yes="Yes", No="No"}; -- if you do not want to use mealState then set following variable to "No" -- otherwise to "Yes" local useMealState = "No"; -- GuestState is predefined global variable with possible values: "Yes", "No". -- If "Yes" it will set lights to predefined level with dimVDGuest & dimDIMGuest, -- also timer is disabled and lights will stay on until set to "No" guests -- if this global variable is added to to section bellow: -- GLOBAL VARIABLES STATE TO KEEP LIGHTS ON! local guestState = "GuestState"; local guestStateMapping = {Yes="Yes", No="No"};
What's New in Version 1.4.3 See changelog
Released
CHANGES
- Added support for Philips HUE AIO VD v3.0 (up) standalone version
- Optimized code
UPDATE
- Save current VSL scene version settings by copying to plain text editor
- Paste new VSL scene version over the old one
- Copy your settings from old to new version
NOTE
- This new version can still control old versions of Philips HUE VD but you must change type to "VDHcst" and correct buttons and sliders order number.