Dimmer Level Based On Mode Or Time


#1

1) Give a description of the problem
I can’t figure out how to have my GE dimmer switch come on at 20% at night, and 60% brightness during the day. Could be determined by location mode, or by time ranges. How can I pre-set the dimmer level without the lights coming on? And what is the difference between the “Set Level”, “Adjust Level”, and “Toggle Level” actions in webCoRE?

2) What is the expected behavior?
In DAY mode, turning on dimmer switch results in turning on to 60% brightness. During NIGHT mode, turning on dimmer results in turning on to 20% brightness. Would be this way regardless of whether switch is turned on physically or programmatically.

3) What is happening/not happening?
In my first attempt, just using a “set level” command based on mode, it turns the lights on when the mode changes (albeit to the correct level, but I don’t want them to come on until I flip the switch myself). In my second attempt, I used the switch turning on as a trigger, and compared the current brightness to what I want it to be based on mode. It works, but is too delayed. I would like the lights to come on to the correct level right when the switch is activated, not turn on to the wrong brightness and then adjust several seconds later.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)

Thanks!


#2

Here’s what I wrote last week to replace the 2 piston setup I had in C0RE. tested for a few days so far and all seems ok. I have master virtual switches for each group of lights (created in IDE). It will turn on and off all lights and track/dim the slider.
Just change the variables at the top and leave the code alone unless you don’t have a LUX sensor. I have global vars for 3 levels of light outside so my lights don’t come on if it’s sunny.
I was going to share this as an example as soon as I was sure it worked correctly. :slight_smile:


#3

daven, thank you for the reply. I think it makes sense for the most part. I do not have a lux sensor, or motion sensors yet, though. Do you know if a similar idea is possible without a lux sensor and just based on mode?

Also, since you are using a virtual switch to control the light group, does that mean you have to activate the lights from the app? I would prefer to retain physical control at the light switch on the wall if possible, both for convenience and friendliness for guests and others in the household.

I guess what I’m probably looking for is to be able to modify a physical switch’s “last known dim value” without turning it on, but I do not know if this is even possible.


#4

You can delete the “and LUX…” line to stop that decision.
Everything in my house is motion based and I have 2 tablets (one on each floor) running ActionTiles so the virtual switch is readily available.
You could assign the MasterSwitch to a physical switch and it should still work.
Hopefully - Ha!


#5

Gotcha, thanks. I don’t think it works for my current use scenario but I like your piston and maybe if I get some LUX / motion sensors in the future it will be useful to come back to.

I have now realized that it just isn’t possible with GE dimmers to “pre” set the dimmer value without turning the switch on.

All attempts to have it adjust level when turned on or slave a virtual switch to it result in a processing delay that sort of defeats the purpose of having a light come on dim at night. Whether it’s a delay from webCoRE or the switch not reporting it’s status instantly.

Anyways, thanks for your ideas. I guess it’s time to shell out for some motion detectors!


#6

Ah yes, you can’t indeed set the levels ahead of time. Found that one out years ago :frowning:
Same with the magical “double tap” that only works on a few switches.


#7

What model switch are you using?


#8

I’m using a GE/Jasco Z-Wave Dimmer with Accessory Switch in a 3-way setup. I’m also using a custom device type handler from the forums that unlocks the controls for dimming steps and speed. Perhaps that is contributing to the delay.


#9

Mine are the original GE switches ST sold from their web site.


#10

Is there a way to progressively dim lights as it gets dark out? I figure this can be done with time til sunset or an outdoor LUX value. I have a crude piston that sets hard coded light lvls based on time but I was hoping there is an easier and cleaner way to dimm the lights more gradually.

How would I write the logic for something like: starting at 2hrs before sunset light lvl = 100% - 1% for every 3min until sunset? Basicly I want them to scale down from 100% to 35% starting 2 hours before sunset.

This is what I am working with now…


#11

In the piston below, I run a calculated dimmer value at the top of the piston that increased brightness until sunrise, and decreases brightness starting at 8pm. Between sunrise and sunset it’s 100%. If any of the expression or functionality is unclear, let me know and I’ll walk you through it.

Note: this does NOT continually dim lights, it sets them at a specific level when they are switched on. To dim them over time, a timer could be used to trigger the piston every minute or 5 minutes, whatever you’d like it to do. But this has the dimmer values based on time you’re after, and it includes preset minimums so my lights are never below 15% (my brand are fairly useless at illuminating my kitchen below that mark).


#12

Thank you! this is just what I was looking for. Is Occupancy a global variable or something, where is that value coming from?


#13

Yeah, it’s a global variable generated by another piston. I use it to trigger lighting events, Garage doors, and other things as it changes. That way I can set up different lighting for “someone is coming home to an empty house” versus me coming home and the wife is already watching tv and relaxing. I’d get some grief if I cranked all the lights up to 100% in the latter scenario, lol.


#14

Is there a way to start decreasing brightness x amount of hours before sunset? I thought I could tweak the expression to use $sunset in place of 8 but I dont understand the value Im getting from $sunset, is it seconds miliseconds? Not sure how to convert that into 12hr time format.

Sunset is around 6pm right now at my location and my $sunset/1000 is showing 1518563940


#15

Yeah, that should be pretty easy. We’ll fix the ‘inner’ part of the equation first, then the front side. For your dimmer calculation based on sunset, this is where the 8pm is hardcoded:

To use sunset as a baseline, change it to this:

From there we can add (negative) hours, or minutes would give you more granularity, to start the fade earlier:

^This will start to decrease your level by 1% per minute at 75 minutes before sunset. So at sunset you’ll be at 25%.

Whatever offset you come up with in this expression, you’ll need to copy into this as well. Currently if time is between sunset and sunrise, it sets the value at 100% and would not continue evaluating the rest of the expression.

Make sense? Ping me back if not and I’ll try to help more!


#16

ah yes that makes sense, I’ve modified my piston and I’ll see how it goes this evening. Thanks!


#17

Need some help. I found this piston and have been trying to work with it but I needed to understand it better.
Why are we dividing by 60000 in the following equasion (100-($sunrise-$now)/60000? What exactly does the $sunrise and $now variables provide us in terms of time (ie seconds minutes etc). How does using 60000 fit into this?

Joe


#18

Both $sunrise and $now are presented in epoch time. Epoch time is measured in milliseconds - 1/1000th of a second.

So 1000 = 1 second, 60,000 = 1 minute


#19

Hello, thanks for creating this piston. After importing it, I was unable to get it to work correctly. I checked the logs and I see this error message: “║An error occurred while executing the event: java.lang.NullPointerException: Cannot get property ‘v’ on null object”

Would you please help me figure out what my issue might be?

Thanks.


#20

Can you post a green snapshot of the piston you’re working on? Sounds like one of the devices and/or parameters isn’t right.