I can’t help you with the JS script side (which I know was your ask…). But if you want to use the JRuby library instead, what I think that code is trying to do is turn off any members of gLampen that are currently ON is that correct?
The JRuby with helper library would be: gLampen.ensure.off
That warning is something you can ignore for now. I get it too and it has something to do with the loading of the helper library as far as I can tell. All it’s telling us is that it’s not going to be able to monitor the library and load a new version should a new version appear. This is unlikely to happen for most users so it can be ignored.
I figured that out by looking at the code for the library. I’ve taken a note to add a comment to the docs that when you need to do something that the library doesn’t support we have access to the raw Java Item Object.
Must be a super duper slow machine. But note that it’s not the script that is processing it, it’s core openHAB. It’s all done on the event bus. Your script will return almost instantly.
I thought there was but couldn’t remember if it was this library or the old Nashorn one.
Anyway, as a reference document, the current docs for the add-on are really quite complete and you can even click through to get to the raw source code. It should be everyone’s first place to look.
Yes, and maybe some items might have 0.0, 0.00 or even 0.0000000 as number format which I also need to care of. Me, as a non-coder, I thought getStateAs method is quite elegant. But probably not. Are there any concerns regarding rawItem.getStateAs?
This could be handled by parsing the state to float and comparing with float, but I have to admit that the OnOffType solution is easier then (at least for a “non-coder”).
It is elegant. There are not really larger concerns about using it, just remember that it is a Java Type and you cannot handle it like a JS type. There are some incompatibilities between Java and JS types.
I guess it is easier for both of us if I explain in German what I meant to say:
Also du kannst den OnOffType und .rawState.getStateAs benutzen, dass macht deinen Code auf jeden Fall kürzer da OnOffType.OFF nunmal OFF für Switch Items ist aber auch 0 für Dimmer Items etc.