Scotsman
(Patrick Beard)
1
Hi,
If I want to test an items state for being greater then 0 but less then 15 what is the correct syntax?
If(Lux.state > 0 && Lux.state < 15) {
//do something
}
Some script examples iv’e seen show how powerful the language is so I wonder if the above is a bit of a bloated way to acheive this.
Thanks
hr3
(Harry)
2
If Lux is a number-item and you use 2.3 it sould work.
Scotsman
(Patrick Beard)
3
Yes it does work but as I’m new to openhab2 scripting moving forward I just wondered if there was a more efficient way of writing it.
hr3
(Harry)
4
In the past the syntax was
If ((Lux.state as DecimalType) > 0 && (Lux.state as DecimalType) < 15) {
so I think this is a proper way and it’s java like.
Scotsman
(Patrick Beard)
5
Great - thanks
I’m trying not to learn bad habits or lazy coding.