Auto Dimmer smartApp (Sept 2015 V2 update)

Ah, got it.
The auto adjust functions as a built in ramp function while the dimmer is on.
When this option is selected, auto dimmer listens for lux events, then adjusts the current dimmer level by the selected percentage until it meets the dimmer level that you have configured for that specific lux range.
It adjusts the dimmer level by the percentage selected every minute, until the new level is met.
I use 1%, since this level change is almost imperceptible.
These events can be seen in the ide live logging.

Basically if you were to leave a light on all day, the level would automatically adjust to follow the settings that you have configured.
If this option is not selected, then the only way to reset a dimmers level (reevaluate the current dimmer level against lux) is by turning it off, then on again.

In my case I have an Fibaro mounted outside, it reports current lux values as they change, so the auto dim feature works well in this case.

Thatā€™s a very well thought out option Mikeā€¦makes sense now. The weather station LUX is not very precise, so tracking it will likely see little benefit. That said, Iā€™m going to look at the Fibaro device.

Iā€™ve noticed that the zigbee bulbs run a lot cooler when dimmed, so this app is about perfect to manage this. I havenā€™t done power measurements at all on zigbee dimmed bulbs, but Iā€™m guessing your app has the potential to save a fair bit of power. Thanks again.

Probably less power draw, no idea really, I created this as I got tired very quickly of being blinded in the morning by my LED can fixtures and wanted something to take care of the dim levels that didnā€™t require constant dinking with or required static settings that had no relation to how much lighting was required at any given point in the day.

While thereā€™s not a lot of commentary about this app, it does have over 200 downloadsā€¦

Some information for those looking to pull LUX from the free Smart Weather Tile for this app:

A. Install the Smart Weather Tile from the web IDE as a device for yourself. There is a template provided. You just need to define a zip code in the device settings

Iā€™m not in the US, so a zip code does not work for me. Fortunately you can leave it blank and your hub location will be used. Alternately you can enter in a weather underground station ID (pws:STATIONID). If you look on the weather underground web site for your area, you can find stations near you. Look in the web URL for the pws:STATIONID and enter that into the device settings for the Smart Weather Tile (instead of a zip code) on your smartphone. I tried a few until I found one with more accurate LUX updates.

B. The weather tile doesnā€™t update itself, and the programs I tried to fix it donā€™t work as they seem to have timer issues. This one, using events to trigger updates, worked perfectly: ā€œManual Weather Refreshā€ written by Daniel Vorster: Smart Weather station tile app
I copied the code and published the app to myself using the web ide. This app updates the weather tile perfectly driven off events, rather than timers. Being that I have lights activated by motion sensors, I used one of those sensor events to trigger a Weather Tile update.

Loving the auto dimmer :slight_smile:

1 Like

How much power does a dimmed Zigbee LED bulb use? I could find nothing using Google with respect to that question, so here you go :slight_smile: Mike, it turns out using the Auto Dimmer app can save a lot of power. In our Kitchen for example we use 7 Ecosmart LED downlights in Halo track and at full brightness, itā€™s simply too bright, even at night. I have these dimmed down to 20% during the day. I found that the Philips Hue and GE-link bulbs run a LOT cooler when dimmed, which Iā€™m guessing will only increase their life, and save power doing it.

Because the SmartThings Zigbee controlled wall plug reports power use in the iOS app ā€œNotificationsā€, I just used that to read power as I set the bulbs at various brightness levels. The bulbs were removed and installed in my shop trouble light, plugged into the SmartThings outlet, for testing.

GE-link at full bright:

GE-Link at 50% brightness:

GE-Link at 25% brightness:

Philps Hue White at full brightness:

Philps Hue White at 75% brightness:

Philps Hue White at 50% brightness:

Philps Hue White at 25% brightness:

2 Likes

Thank you @Mike_Maxwell !!! :astonished::joy:

I needed a way for all the lights in my house to constantly self-adjust to have rooms evenly lit:

  • minimize perceived visual contrast such that interior lights coordinate to seamlessly ā€œmatchā€ one another
  • and also ā€œmatchā€ the exterior daylight level, appreciating how bright\dark the roomā€™s exterior window happens to be at any moment. :sunrise: :white_sun_small_cloud: :sunny: :white_sun_cloud: :thunder_cloud_rain: :crescent_moon: :milky_way:

Your AutoDimmer app is the reason I bought a SmartThings hub, and am now in process of buying a ton of new dimmer switches\outlets, as well as learning how to properly code on this platform.

Iā€™ve got a few wishes\ideas to help add AutoDimmer functionality. Before I get too far along down that road, may I ask, are you still interested in enhancing this app :slight_smile:?.. ā€¦or has this app since been deprecated :sweat:?

YIKES, I have noticed a marked degree of developer unhappiness over the SmartThings platform as of late :skull_crossbones: ; maybe I should have pinged you on a better day

Iā€™m still here, and the app is still in use and supported my me.
Glad you like it!
What did you have in mind?

2 Likes

Was hoping to save you time by making all the code changes myself (and then um, pull request?) but oh no! Iā€™m finding ST is terribly lacking in the VisualStudio\IntelliSense\Step-Thru-Debugger\ObjectOriented type functionality that I usually depend on to sling out rapid dev work that works as needed. Therefore am afraid it is going to be a long while before I get through enough ST learning curve to make meaningful progress. Gotta keep my day job.


Wish-A
Currently the dimmer level % preference values are restricted to increments of 10%. Turns out I need 1% increment granularity otherwise several of my light fixtures are slightly too bright\dim. Yeah, call me Goldilocks. I see thereā€™s a ST option to code as a numeric range (type:ā€œnumberā€, range:ā€œ0ā€¦100ā€) but then I loose the nifty displayed ā€œ%ā€ unit identifier you provided via enum. I can manually edit the existing enumā€™s to add in all 101 individual % values [0,1,2,99,100] easy enough, but then I feel a lil contrived, like it should be a GUI slider or something.
ā€”Btw on a separate but slightly relate note, I tried my hand doing a similar thing with the LUX pref values, but using a dynamic range (ā€œ${luxDark}ā€¦*ā€) and submitOnChange to allow for arbitrary integer values while still preventing user from accidentally overlapping their LUX threshold settings (luxDark < luxDusk < luxBright). Didnā€™t quite work tho, might be too advanced\messy for now; k nevermind that on the LUX values.


Wish-B
Currently the AutoAdjust ramp rate % values are restricted to [1,2,5]. Wish it had larger rate values for a number of reasons. I manually edited the enum to add ā€œ[ā€¦,10,100]ā€. The ā€˜100ā€™ basically acting as an ā€œinstant\ramplessā€ AutoAdjust speed.

If Iā€™m understanding the AutoAdjust logic correctly, then the above 2 Wishā€™s might cause out-of-range and endless-dimmer-teetering problems when the dimmer%\LUX integer preference values arenā€™t evenly divisible. So to safeguard, think I just have to add in a Math.MIN\MAX to these 2 lines (right?) like:

if (crntDimmerLevel < newDimmerLevel){
	rampLevel = Math.min( crntDimmerLevel + rampInt, newDimmerLevel )
} else {
	rampLevel = Math.max( crntDimmerLevel - rampInt, newDimmerLevel )
}

Wish-C
Currently the AutoAdjust bool and ramp rate % preference is provided separately on each individual dimmer switch deviceā€™s dynamic pref page. Love this feature but I have sooo many individual dimmers to keep tweaking and re-configuring (first world problems). Wish these 2 AutoAdjust settings were also available at an app instance ā€˜defaultā€™ level. Kinda like the dimDark\dimDusk\dimDay\dimBright preferences, where I could set it once and then optionally still proceed to visit the per-dimmer dynamic page to explicitly opt in\out (bool?) and\or tweak ramp rate % of a specific dimmer switch. I do get how to code part of this, but not yet comfortable enough to implement without breaking too much of something else; looks like this impacts several lines throughout the app.


Wish-D
Currently the app doesnā€™t accept a name (aka ā€˜labelā€™?). Wonā€™t this be awkward when I install multiple instances of this app (maybe one for each side of the house), but have no way to label which is which? I did start trying to add in the ā€œlabelā€ preference per documentation, however so far Iā€™m just ending up with several orphaned installed app instances that do NOT appear in the ST Android app but DO appear in the ST IDEā€™s list of installed SmartApps. Starting to suspect either outdated ST documentation or a ST bug, but hopefully itā€™s just [me] user error cause thatā€™s way easier\faster to correct.


Wish-E <ā€” Whoa, I need to contemplate this one after Iā€™ve had more time with ST.
Currently the app allows for only 1 illuminance sensor (per installed app instance). What about my rooms that span either side of the house, with a wall of exterior windows facing the sunrise and another wall of windows facing the sunset. Can I handle this ā€œbipolar gradientā€ room as-is using multiple app instances? Maybe. But the first knee-jerk thought that came to mind was a desire for 1 app instance to accept multiple illuminance sensors. In which case would probably also need to accept a predefined ā€œmulti-LUXā€ aggregation option {MIN\MAX\AVERAGE} (ā€˜WeightedAverageā€™? hmm I donno) on the default pref page as well as the per-dimmer dynamic pref pages. Or I guess same could be achieved via a separate virtual multi-LUX aggregator illuminance sensor; has someone already developed such a virtual sensor?


Wish-F <ā€” Whoa, I need to contemplate this one after Iā€™ve had more time with ST.
Currently the app allows for 3 static LUX thresholds, resulting in the brightness detection being constrained to a resolution of 4 possible brightness levels. Maybe thatā€™s good enough (I hope so). But if turns out to need a more fine-grained resolution, then may be nice to upgrade logic into a more dynamic function curve type of interpolation. The ā€œLux Auto Brightnessā€ Android App [in Google Play Store] comes to mind as a working example of this functionality: user supplies an array of {Lux->DimmerLevel%} key\value pairs [ {0lux->5%} , {100lux->20%} , {1000lux->100%} ] with as many (or few) pairs as desired, and then the app effectively smooths out the gap between each supplied pair at runtime.

Short initial reply, will take more time than I have right now to sort through all these.
The case for Enums are two fold, a, I donā€™t like unconstrained ad hoc user inputs, and b, until very recently submitOnChange did not work for numeric values on android. If range limits on inputs work now, I may consider changing To numeric. In any event changing the enum list isnā€™t that big of a deal.
Have considered the need to support additional lux sensors, this could be done on a per dimmer override, like the levels, however this seems clumsy to me, better approach I feel would be to create a zone configuration where by the zone options can dictate the overrides for the selected dimmers if desired.
Adding an app label is easy enough, however this could be solved by the zone parent child implementation, thus keeping app sprawl to a minimum.
Regarding the gradient vs static range interpolation, while it makes sense, from a practical perspective in two years of use 4 ranges have proven to be more than enough to achieve the desired effect.
Also keep in mind the desire to keep the ui simple enough for the average user to configure and use.
Iā€™m not getting the auto ramp value range expansion, personally I do not like abrupt changes for this modeā€¦, if all dimmers supported decimal values I would have implemented that, anything over 1% incremental changes per cycle is distracting imho.

Iā€™m liking the options a zone implementation provides, optional lux sensor, optional zone overrides.
Lux averaging for multiple lux sensors at the global level also makes sense.

Iā€™ve also been looking for an excuse to refactor/re write this app as the core functionality hasnā€™t changed much in two years.

3 Likes

Hurray, I ended up able to add in this parameter and make the corresponding code changes after all. Lets me easily enable AutoAdjust on all my lights with 1 tap.

Yes, I do rather like the self-guidance (dummy-proofing) benefit the Enumā€™s add to the user experience.

Turns out I WAS supplying the correct label code all along, but just wasnā€™t visible in the mobile app due to a SmartThings bug (child app discovery checkbox); bug which has since been fixed.

:grinning: That does sound nice! Iā€™m thrilled to hear this has already crossed your mind.

After several more weeks using this in the main room, Iā€™m starting to suspect the 4 ranges are going to suffice for me too (thank goodness).

I too am finding anything over a couple % to be distracting.
The value I get from having a ā€œ100%ā€ ramp rate option is to help me in the initial lux\dimmerLevel preference tweaking phase throughout the day. I may be in this phase for a while, till I figure out exactly which lux thresholds and dimmer levels work out best for each room. The resultant instant (abrupt) autodimming behavior allows me to more easily notice when (and if) the auto-dimming is kicking in, and also saves me time that Iā€™d otherwise have to wait for the more gradual 1% [per minute] rate.
Eventually once I narrow down luxThreshold\dimmerLevel pref settings for each room, then I expect to revert back to the more gradual 2% or 1% rate.

I donā€™t want to pack in so many features as to render the code too monstrous to support or too susceptible to platform bugs. :sweat: I see what happens.

When lights are first turned on after a lux change the lights come on at the previous dim setting then 1-2 seconds later switch to the new setting. Is this something you guys see?

Example. lights were last on at 60% (not from physical switch, but from this app) and then later in the day the light turns on at 10% from this app. The light comes on at 60% (previous setting) then switches to 10% 1-2 seconds later? Iā€™m not sure if Iā€™m doing something wrong in how Iā€™m using this app.

I have apps turning the dimmer on, but with no level instruction. auto Dimmer sets the level. Itā€™s just very disruptive to have the change in level especially when itā€™s dark and you want a low light, but it comes on bright first before dimming to the correct level.

Happens to me. Not sure it can be fixed unless dim level could be set without the light being turned on.

yup, thatā€™s the way the app works, nothing can be done about this on the code end of things, these dimmers just donā€™t have a way of presetting a dimmer level.
I wrote the app this way so that the dim level would be modified the same way when turned on via ST or the physical switch.

Perhaps in the device type? I remember someone had written a DTH for the GE link that gave it the option to dim to on and dim to off. It also added an option for the speed at which the dim happened.

that would fix it, wouldnā€™t to be too hard to implement with any dimmer actuallyā€¦
find the off command then change it to this delayBetween( ā€œzwaveSetLevel, 0 or 1ā€, ā€œzwaveOffā€)
just replace the command text with the actual commands.

Which dimmer do you have? Most (all?) can turn on at a specific level. Try having whichever smartapp youā€™re using set the dimmer level to 1 instead of having it turn lights on.

For example, in Rule Machine have it
"Set these dimmers"
"To this level"
1

In SmartRules
SET LEVEL
1

Do not turn ON the lights first, just set the level.

(The DH will typically send a basicSet or switchMultilevelset to the device with the new level, which will turn on the device at the new level.)

Well that doesnā€™t work if you are using motion events to turn the light on.

Motion - app sets level 1 - Auto Dimmer raises to preferred level. motion goes inactive, but not long enough to turn the light off. Then a new motion event will cause the app to change the level to 1 - then auto dimmer will raise.

Sorry, could you clarify the steps and the smartapp youā€™re using (smart lighting?)

@Mike_Maxwell Is there a way to globally set the lux following? Itā€™s pretty tedious doing it for every bulb - ideally a global lux track and increment level?

Sure there is, just canā€™t tell you when Iā€™ll be able to do it!

2 Likes