Hello
Thank you for your time and answer
Lux will be from 6000 to zero but should first kick in at 200 (tusk, dusk or twilight, whatever you call it .
Bulb will be from 0 to 100, I would like it to run 0 to 30 and yes they are inversely connected
Language whatever can do the task, rulemachine however will be fine.
def LUX = 1000
def BULB = 0
// If LUX is less than or equal to 200, always set BULB to 1
if( LUX <= 200 )
BULB = 1
// Else if LUX is equal to 6000, always set bulb to 30
else if( LUX == 6000 )
BULB = 30
// Else, the LUX is between 201 and 5999.
// LUX divided by 200 will always give us a value between 1 and 30, but we need the inverse
// Just subtract the quotient from 30, and it will invert the relationship.
// Now, LUX of 5000 yields BULB of 5, while LUX of 1000 yields BULB of 25
else
BULB = 30 - ( LUX / 200 )
println BULB
EDIT: I may have still misunderstood.
You want the bulb to range from 1 to 30 ONLY while lux is between 0 and 200? If this is the case, I'll have to edit. If you are wanting the bulb to range from 1 to 30 while lux is between 200 and 6000, the code above will work fine.
Yes exactly, sorry if I have not been prezise enough
The idea is that my light levels should slowly kick in when darkness apears
However, in winter tusk is shorter than in summer, as well as a thunder or heavy rain would change light conditions