Author Topic: Help with turning off dimmer when light hits 1%  (Read 1981 times)

Offline Greybeardvacationrental

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
Re: Help with turning off dimmer when light hits 1%
« Reply #15 on: May 28, 2018, 10:11:40 am »
If you update your PLEG routine that turns it off to ALSO set a value on the variable "LoadLevelLast" to 100, that would allow the switch to come back on at 100% brightness. I can't guarantee that's the variable name you'd need to use because I don't have any of the GE Dimmers in use - mine are all Leviton. You can check the Advanced settings for the device and look at the Variables tab to find what it's actually called on your switches.

I'm not sure how to go about this.  I've managed to reset my switch to turn off when it's dimmed to 4% or lower.   And when I hit the On button it does not come on because the last known set was 4% and it turns it off again.  I've gone into the Action tab and have tried to add a second action from that device to set the "LoadLevelLast" to the desired % so that when you turn the light on again it will go to a set level but after picking the device for a second time in the "Select Device to Add to Current Interval" and then going to the action drop down to the right "LoadLevelLast" is not listed.  Actually the commands in this list do not match at all the commands I got when I added the device to the "Device Input" tab.

I even tried adding a whole new Device Input just for "LoadLevelLast" and putting the same conditions on it and then go to the Action.  Again the fields to choose from are completely different than the fields from the Device Input.  I do not see a "LoadLevelLast" to set in the action drop down.


Offline Greybeardvacationrental

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
Re: Help with turning off dimmer when light hits 1%
« Reply #16 on: May 30, 2018, 03:58:20 am »
Is there anyone that could possibly help me with this?  Write a script of code or something?   All of my dimmers have "LoadLevelTarget", "LoadLevelLast" and "LoadLevelStatus" in the variables under the advanced tab.  The goal:

When the switch is dimmed to 4% or less the switch turns off and sets the "LoadLevelLast" to a desired % depending on the dimmer. 

Thanks in advance to all the experienced ones out there.

Offline ember1205

  • Sr. Member
  • ****
  • Posts: 416
  • Karma: +5/-21
Re: Help with turning off dimmer when light hits 1%
« Reply #17 on: May 30, 2018, 11:49:05 pm »
Create a scene that is triggered by the light being turned off. There is no immediate or delayed action, but you will need it to run a piece of LUA code to set LoadLevelTarget and LoadLevelLast to some value (same for both) which will become the lighting level when they are turned back on again.

The LUA code will need to be something like (this is off the cuff, so no guarantees here):

Code: [Select]
luup.variable_set("urn:micasaverde-com:serviceId:ZWaveDevice1","LoadLevelTarget","XX","YY")
luup.variable_set("urn:micasaverde-com:serviceId:ZWaveDevice1","LoadLevelLast","XX","YY")

XX should be the percentage you want to set the dim level to and YY would represent the ID of the specific device.

Also, be advised that turning the lights back on "right away" will possibly not work because of a delay in Vera polling the switch to find out it has been turned off. So, the resetting of the dim value may take a short bit to be populated to the switch.
« Last Edit: May 30, 2018, 11:51:23 pm by ember1205 »

Offline Greybeardvacationrental

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
Re: Help with turning off dimmer when light hits 1%
« Reply #18 on: May 31, 2018, 04:43:01 am »
Create a scene that is triggered by the light being turned off. There is no immediate or delayed action, but you will need it to run a piece of LUA code to set LoadLevelTarget and LoadLevelLast to some value (same for both) which will become the lighting level when they are turned back on again.

The LUA code will need to be something like (this is off the cuff, so no guarantees here):

Code: [Select]
luup.variable_set("urn:micasaverde-com:serviceId:ZWaveDevice1","LoadLevelTarget","XX","YY")
luup.variable_set("urn:micasaverde-com:serviceId:ZWaveDevice1","LoadLevelLast","XX","YY")

XX should be the percentage you want to set the dim level to and YY would represent the ID of the specific device.

Also, be advised that turning the lights back on "right away" will possibly not work because of a delay in Vera polling the switch to find out it has been turned off. So, the resetting of the dim value may take a short bit to be populated to the switch.

Thanks for the suggestion.  In a pinch it would be a solution.  If I do that though then I do lose the function of the light switch that is enjoyed by those that understand how to turn the dimmer switches on and off.  If you set your light to 75% you should be able to tap it to turn it off and then tap it to turn it back on at the same level you had it at.  What I would rather do is make it an "if/then/AND" situation.  If someone dims the light down to below 5% to "turn it off" I'm going to assume that they just don't know how it functions so I'd like the possibility of IF the light is set to below 5% THEN turn the light off AND set the LoadLastLevel to XX.   I can get the first part of that in PLEG by creating the IF below 5% then do the action.  It's just that the action in PLEG gives me the option of turning it off using "LoadLevelTarget" but it does not give me the option to of "LoadLevelLast" even though that is in the list when I create the Device Input. 

Offline Tillsy

  • Full Member
  • ***
  • Posts: 207
  • Karma: +9/-3
Re: Help with turning off dimmer when light hits 1%
« Reply #19 on: May 31, 2018, 05:30:42 am »
Does your dimmer return wattage like Fibaro and Aeon devices?

If so turn your light down to the level you would like to trigger, say 5%, and check what Vera shows the wattage as (give it a while as power levels are generally only sent at intervals).

Then create scene, select your dimmer, and select "Energy usage goes below".  Key in your wattage from above.

Then you can enter your LUA code to be executed.

Offline Greybeardvacationrental

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
Re: Help with turning off dimmer when light hits 1%
« Reply #20 on: May 31, 2018, 05:39:49 am »
It does have a LoadLevelStatus.    This variable shows the percentage of dim that is is currently on.  So yes.  I have that ability to see where it is at.  What I do not know how to do is write code that says

If LoadLevelStatus <= 4  then Set LoadLevelStatus = 0  AND  Set LoadlevelLast = xx

Right now I'm trying to use PLEG.  In Pleg I can create the Device Property LoadLevelStatus (P1).  And then I can create the IF P1 <= 4 then (and this is where it gets funky because when I go to the action part of PLEG It does not have any of the same variables that the switch has but it does have LastLevelTarget) So I finish my PLEG with IF P1 <=4 then ACTION LoadLevelTarget = 0.  This turns the switch off when the dimmer is set to 4% or below.  I just need to figure out how to get the AND part of that to set the LoadLevelLast to a desired number.  And LoadLevelLast is not part of the Action options even though it's a device variable. 

Offline Don Phillips

  • Hero Member
  • *****
  • Posts: 1259
  • Karma: +31/-32
Re: Help with turning off dimmer when light hits 1%
« Reply #21 on: May 31, 2018, 08:08:01 pm »
In the action, you can add another instance of device so it appears twice.  Here is an example of my thermostat.

You should be able to set LoadLastLevel to XX and in the second instance, LoadLevelStatus to 0.
Vera 3, 1.7.1030, CT101 t-stat, Everspring motion detector, GE/Jasco switch, Leviton outlet, AeonLabs sensor, NuTone garage door, Blue Iris, Sricam SP011, iPhone locator, APCUPSD, VeraMate, VeraAlerts, PLEG, House Modes, Countdown Timer, DVR, Virtual/Multi Switch, Weatherunderground, LB60Z-1 bulb

Offline ember1205

  • Sr. Member
  • ****
  • Posts: 416
  • Karma: +5/-21
Re: Help with turning off dimmer when light hits 1%
« Reply #22 on: June 01, 2018, 11:54:07 am »
It does have a LoadLevelStatus.    This variable shows the percentage of dim that is is currently on.  So yes.  I have that ability to see where it is at.  What I do not know how to do is write code that says

If LoadLevelStatus <= 4  then Set LoadLevelStatus = 0  AND  Set LoadlevelLast = xx

Right now I'm trying to use PLEG.  In Pleg I can create the Device Property LoadLevelStatus (P1).  And then I can create the IF P1 <= 4 then (and this is where it gets funky because when I go to the action part of PLEG It does not have any of the same variables that the switch has but it does have LastLevelTarget) So I finish my PLEG with IF P1 <=4 then ACTION LoadLevelTarget = 0.  This turns the switch off when the dimmer is set to 4% or below.  I just need to figure out how to get the AND part of that to set the LoadLevelLast to a desired number.  And LoadLevelLast is not part of the Action options even though it's a device variable.

I think you have to make a choice here... either work with PLEG and the ease of use combined with the lack of deep flexibility (like this - combining variable settings with simple controls), or learn how to write code for programming to generate your own controls and events.

If you were to drop the PLEG routine you have all together, you could replace it with a single scene in VERA that would detect that the switch had been turned "way down" (less than 5%) and then turn it off AND change the settings. Otherwise, someone turning the switch off correctly would allow it to come back on at that level. This is a MUCH more elegant solution overall (IMHO) because the scene can be set with the trigger point literally being "less than 5%" and the action being the LUA code. A normal "OFF" event is ignored.

Offline Tillsy

  • Full Member
  • ***
  • Posts: 207
  • Karma: +9/-3
Re: Help with turning off dimmer when light hits 1%
« Reply #23 on: June 01, 2018, 09:07:06 pm »
Or, how about this... does your dimmer have a configurable parameter for minimum and maximum brightness levels like Fibaro devices?

If so, set the minimum brightness to say 10%.

Then it won't even be possible for someone to dim it to the point where they "think" it is off, the lights will still be on at a very obvious level and then they still have to turn it off.

Offline Greybeardvacationrental

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
Re: Help with turning off dimmer when light hits 1%
« Reply #24 on: June 02, 2018, 04:34:05 am »
In the action, you can add another instance of device so it appears twice.  Here is an example of my thermostat.

You should be able to set LoadLastLevel to XX and in the second instance, LoadLevelStatus to 0.

Thanks Don.  I have tried this but the options in the ACTION drop down are not the same as the parameters of the device.  There is no LoadLevelLast in the drop down in the Action part of the PLEG.  When I create a Device Property and choose a dimmer I see all the parameters of that dimmer.  But by the time I get to the Logic Actions and then try to choose what action I want those same parameters are not there. 

Offline Greybeardvacationrental

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
Re: Help with turning off dimmer when light hits 1%
« Reply #25 on: June 02, 2018, 04:37:21 am »
It does have a LoadLevelStatus.    This variable shows the percentage of dim that is is currently on.  So yes.  I have that ability to see where it is at.  What I do not know how to do is write code that says

If LoadLevelStatus <= 4  then Set LoadLevelStatus = 0  AND  Set LoadlevelLast = xx

Right now I'm trying to use PLEG.  In Pleg I can create the Device Property LoadLevelStatus (P1).  And then I can create the IF P1 <= 4 then (and this is where it gets funky because when I go to the action part of PLEG It does not have any of the same variables that the switch has but it does have LastLevelTarget) So I finish my PLEG with IF P1 <=4 then ACTION LoadLevelTarget = 0.  This turns the switch off when the dimmer is set to 4% or below.  I just need to figure out how to get the AND part of that to set the LoadLevelLast to a desired number.  And LoadLevelLast is not part of the Action options even though it's a device variable.

I think you have to make a choice here... either work with PLEG and the ease of use combined with the lack of deep flexibility (like this - combining variable settings with simple controls), or learn how to write code for programming to generate your own controls and events.

If you were to drop the PLEG routine you have all together, you could replace it with a single scene in VERA that would detect that the switch had been turned "way down" (less than 5%) and then turn it off AND change the settings. Otherwise, someone turning the switch off correctly would allow it to come back on at that level. This is a MUCH more elegant solution overall (IMHO) because the scene can be set with the trigger point literally being "less than 5%" and the action being the LUA code. A normal "OFF" event is ignored.

Thanks.  I agree.  I am just making sure I'm not missing something in trying to use the system or the plug in before I embark on becoming a computer programmer.  But if it is what must be done then I will have to.  Or maybe someone with LUA experience can just rattle it off their hip because they already have the experience.  :) 

Offline Greybeardvacationrental

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
Re: Help with turning off dimmer when light hits 1%
« Reply #26 on: June 02, 2018, 04:39:54 am »
Or, how about this... does your dimmer have a configurable parameter for minimum and maximum brightness levels like Fibaro devices?

If so, set the minimum brightness to say 10%.

Then it won't even be possible for someone to dim it to the point where they "think" it is off, the lights will still be on at a very obvious level and then they still have to turn it off.

Excellent suggestion.  There is no obvious parameter in the advanced settings for the dimmers to set a minimum but I can research it or contact the company to find out if there is a command that I can add.

Thanks!

Offline ember1205

  • Sr. Member
  • ****
  • Posts: 416
  • Karma: +5/-21
Re: Help with turning off dimmer when light hits 1%
« Reply #27 on: June 02, 2018, 02:57:46 pm »
It does have a LoadLevelStatus.    This variable shows the percentage of dim that is is currently on.  So yes.  I have that ability to see where it is at.  What I do not know how to do is write code that says

If LoadLevelStatus <= 4  then Set LoadLevelStatus = 0  AND  Set LoadlevelLast = xx

Right now I'm trying to use PLEG.  In Pleg I can create the Device Property LoadLevelStatus (P1).  And then I can create the IF P1 <= 4 then (and this is where it gets funky because when I go to the action part of PLEG It does not have any of the same variables that the switch has but it does have LastLevelTarget) So I finish my PLEG with IF P1 <=4 then ACTION LoadLevelTarget = 0.  This turns the switch off when the dimmer is set to 4% or below.  I just need to figure out how to get the AND part of that to set the LoadLevelLast to a desired number.  And LoadLevelLast is not part of the Action options even though it's a device variable.

I think you have to make a choice here... either work with PLEG and the ease of use combined with the lack of deep flexibility (like this - combining variable settings with simple controls), or learn how to write code for programming to generate your own controls and events.

If you were to drop the PLEG routine you have all together, you could replace it with a single scene in VERA that would detect that the switch had been turned "way down" (less than 5%) and then turn it off AND change the settings. Otherwise, someone turning the switch off correctly would allow it to come back on at that level. This is a MUCH more elegant solution overall (IMHO) because the scene can be set with the trigger point literally being "less than 5%" and the action being the LUA code. A normal "OFF" event is ignored.

Thanks.  I agree.  I am just making sure I'm not missing something in trying to use the system or the plug in before I embark on becoming a computer programmer.  But if it is what must be done then I will have to.  Or maybe someone with LUA experience can just rattle it off their hip because they already have the experience.  :)

I'm not a programmer by any stretch, but have written all of my own LUA. I start with a simple "If this is true, do that" sort of writeup. Then I add detail to each section until I have what I need.

Offline Greybeardvacationrental

  • Jr. Member
  • **
  • Posts: 75
  • Karma: +1/-0
Re: Help with turning off dimmer when light hits 1%
« Reply #28 on: June 02, 2018, 03:11:37 pm »
It does have a LoadLevelStatus.    This variable shows the percentage of dim that is is currently on.  So yes.  I have that ability to see where it is at.  What I do not know how to do is write code that says

If LoadLevelStatus <= 4  then Set LoadLevelStatus = 0  AND  Set LoadlevelLast = xx

Right now I'm trying to use PLEG.  In Pleg I can create the Device Property LoadLevelStatus (P1).  And then I can create the IF P1 <= 4 then (and this is where it gets funky because when I go to the action part of PLEG It does not have any of the same variables that the switch has but it does have LastLevelTarget) So I finish my PLEG with IF P1 <=4 then ACTION LoadLevelTarget = 0.  This turns the switch off when the dimmer is set to 4% or below.  I just need to figure out how to get the AND part of that to set the LoadLevelLast to a desired number.  And LoadLevelLast is not part of the Action options even though it's a device variable.

I think you have to make a choice here... either work with PLEG and the ease of use combined with the lack of deep flexibility (like this - combining variable settings with simple controls), or learn how to write code for programming to generate your own controls and events.

If you were to drop the PLEG routine you have all together, you could replace it with a single scene in VERA that would detect that the switch had been turned "way down" (less than 5%) and then turn it off AND change the settings. Otherwise, someone turning the switch off correctly would allow it to come back on at that level. This is a MUCH more elegant solution overall (IMHO) because the scene can be set with the trigger point literally being "less than 5%" and the action being the LUA code. A normal "OFF" event is ignored.

Thanks.  I agree.  I am just making sure I'm not missing something in trying to use the system or the plug in before I embark on becoming a computer programmer.  But if it is what must be done then I will have to.  Or maybe someone with LUA experience can just rattle it off their hip because they already have the experience.  :)

I'm not a programmer by any stretch, but have written all of my own LUA. I start with a simple "If this is true, do that" sort of writeup. Then I add detail to each section until I have what I need.

Yeah I'll just have to take some time to figure out how to write LUA code.  One of these days I'll work it in.

Offline ember1205

  • Sr. Member
  • ****
  • Posts: 416
  • Karma: +5/-21
Re: Help with turning off dimmer when light hits 1%
« Reply #29 on: June 03, 2018, 03:48:54 pm »

Yeah I'll just have to take some time to figure out how to write LUA code.  One of these days I'll work it in.

It really shouldn't be all that difficult. Right now, PLEG is detecting when the dimmer drops down below 5%. Your action is to turn the dimmer off at that point. You could change that as follows:

- Create a virtual on/off switch
- Have PLEG turn the virtual switch on when the dimmer drops below 5% (instead of turning the light off)
- Create a scene that detects when the virtual switch is turned on
- - Immediate action is to turn the virtual switch off AND the dimmed switch off
- - LUA code sets the variables we've already talked about

Done.

If someone partly dims the switch and then turns it off, it will come back on at the last level it was dimmed to.