Javascript and HSBType

Hello all,

I’m new to Openhab and OH3 so excuse me if i missed something.
I just started to play with Javascript rules in the GUI and try to send a Color to a Light.
When I try to convert the RGB value to HSV to be able to Send it I fail miserably because I seem to be unable to get a HSBType Object to use the .toRGB function.
What am I missing?

 var HSB = new HSBType.fromRGB(rgb[0], rgb[1], rgb[2]);

What is the correct way to convert RGB to HSV and then send it via sendCommand to an item?

What’s the reported error? How is the rgb array populated? What is the type of the values in the array?

Thanks for taking time and sorry for not being clearer, got a bit frustrated last night…

I actually got it working but stumbled over something else on they way.
I installed the helper libraries as defined here Installation — openHAB Helper Libraries documentation.

Because those libraries where throwing errors I found some updated ones here on the forum (sorry can find the thread now) but essentially the import was changed from eclipse to openhab.

The metadata.js seems to work fine but when I then added the utils.js to my rule somehow all execution seems to silently stop.
In the openhab.log I can see that the rule is updated but nothing further (not even an error).
If I remove the lib it works as expected.

So I guess my ask is how to debug this?
Why is that lib causing everything to stop?
And what is currently the recommended place to get those helpers?
Lastly can i even use the libraries in a GUI Script or are they only supported from file scripts?

I can post the version I have here at the moment if that is helpful.

As I’m a new user and likely a lot of other people will have the same struggle I’m wondering if I can contribute to some documentation (which is really lacking tbh.). I feel searching the community for every little thing is a struggle. But at the moment the scripting documentation seems to be (correct me if i’m wrong) a bit all over the place and I can not see the best place to add something.

@rlkoshak Could you please point me to the best place to help out?

I don’t know what state the JavaScript Helper Libraries are in for OH 3. I haven’t been using them. I know that there is a PR to fix the Python Helper Libraries to work with OH 3 but I do not think the JavaScript ones have been fixed. utils.js seems to do a lot of importing so I would not be surprised if the problem is with one of those imports.

But I would have expected there to be errors in the logs. So I can’t offer any advice beyond adding some logging to the library code itself to see if you can tell where it’s failing.

GitHub - openhab-scripters/openhab-helper-libraries: Scripts and modules for use with openHAB is the official repo for the libraries.

Yes, you can use them in the UI rules. Not all of the libraries will be relevant in UI rules since you will not be dealing with triggers and creation of rules and such.

And contributions are welcome. If you see something you can write please jump in and open an Issue and PR and start contributing. The barrier to contributions is as low as we can make it. However, the Helper Libraries are not (yet?) a part of the openHAB project. Consequently any documentation for them needs to be made in the Helper Library repo, not the main OH docs.

Unfortunately I’m not using the Helper Libraries because until they are released as an add-on most non-technical users won’t be able to get over the hurdle of getting them installed. So I’m focusing my efforts on learning how to do everything without the Helper Libraries.

1 Like