Can you set variables to ranges? I’m trying to set variables for lux levels and would like one variable be 0-100 lux equals dark, 101-400 equals darkish, etc. Is this possible?
Set variables to a range of numbers?
I’m sorry, I’m not following you. You want to set a variable when a number falls within range? Why would you want to set a variable to a range of numbers? Do you have an example you could share because I am not following how you want to use a variable.
If you want the variable to be text (string), then this should work:
(Replace my “SimTemp’s temperature” with your “Device’s lux level”)
(import code: vzfe2)
Sure thing, glad to be able to help.
One last thing, if you have a trigger in the piston, then the lightning bolts shown above will not be there for you, and the statements will be treated as conditions instead.
That’s still not a range, it’s a text string. You’re setting it to “light” or “dark”. I assumed when the OP said set a variable to a range, he/she then wanted to evaluate whether another number fell within that range, which you couldn’t do with a text string. In that case you’d have to use 2 variables, one for the high and one for the low.
Wow I was hoping previous post worked. You’re right I want to have a piston that says if lux falls within range then set brightness to X %
Trying to make a piston so the lower the lux the higher the brightness.
I understand your goals better now. You could try this:
define
integer brightness;
end define
execute
IF Device's lux level is less than 100
then Set variable {brightness} = 75
END IF
IF Device's lux level is inside the range of 100 and 399
then Set variable {brightness} = 50
END IF
If this is to control just a bulb or two, (and you don’t need the brightness stored)
then you can drop the variable, and replace those lines with:
Set Bulb's level to X
Ok I feel like an idiot - I’ve never seen/used that condition before and yet it’s right there in front of me for the taking! Thanks!
Don’t feel bad, I still find myself learning something new with webCoRE nearly every day!