Increase brightness as lux decreases?


#1

Looking for a piston that’ll incorporate a smart weather tile device so that as the lower the lux level the higher the brightness level of a light. Someone recommended a “switch statement” in the Facebook group and never used one before, but looking for additional input. Basic premise is as lux decreases the brightness should increase. What’s the best way to do this?

Here’s the switch statement I started - not sure what to use for the action though. I’ve got set level but maybe it should be adjust level?


#2

You would have to decide how often you want to “poll” the lux level and then evaluate if it’s going up or down. You’d then run that piston every x number of seconds. Using a variable you can compare current to 2 mins ago lets say. And if that has gone up, you could also raise the brightness.

Alternatively, you could apply math to the Lux to bring it into a %. Then, as the lux changes, set brightness equal to A(lux) where A is your conversion factor.


#3

You can’t just say if lux decreases then increase brightness X amount?


#4

Decreases at all? If it drops by 1 you want it to get brighter?


#5

I was thinking something like this but instead of just “rises” instead something like “rises by 100”.


#6

Yes, but you can’t do that. You have to keep track of the current value and then compare it at a later time. Webcore won’t remember what the value used to be. How would it choose how long a time period to save all those values for.
When I mentioned storing the value in a variable, what’s what you’re doing. Rises by x in y a mount of time.


#7

I think I finally get what you mean now - you’d have to keep doing statements like this for each lux/brightness level right? I didn’t do the trigger for the light with a timer though - won’t this work?


#8

No…I’m not writing it out on my phone. You’ll just have to be patient.


#9

Slightly off topic, but for anyone else implementing this idea should make sure your lux sensor is located far away from the bulb you connect it to. (ideally in another room or outside) Otherwise, the bulb’s brightness will affect the lux level for the next data read.


#10

Yeah I’m using a smart weather tile device’s illumanance reading to control the lights. But @Ryan780 is right - I’m doing something wrong since the light isn’t coming on at all. Not sure if I’d need to have a command to turn light on first or whatever but usually set level will turn the light on anyway.


#11

Hmm, isn’t line 32 supposed to be a trigger? (with the lightning bolt in the left margin)


#12

I thought so - “changes” is listed in the triggers section. Not sure why it’s not showing the lightning bolt.


#13

So the light actually did come on - wasn’t coming on before because I forgot to set all the ranges. Need to figure out what other lux levels there are for bright, sunny, overcast, etc. But anyway this error is showing up in the log. Only thing in the log actually. Never seen it before and not sure how to interpret it.


#14

Another thing I can’t figure out is it’s my setting the light to the right level.

Here’s the light set at 80%

But if you loon at the current lux level in my piston state

It should be at 100% because here’s the setting of that variable