# Javascript and HSBType

**URL:** <https://community.openhab.org/t/javascript-and-hsbtype/115521>\
**Category:** Scripts & Rules\
**Tags:** jsr223, rules, javascript\
**Created:** [January 26, 2021, 8:22pm UTC](https://community.openhab.org/t/javascript-and-hsbtype/115521 "2021-01-26T20:22:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael\_p](https://community.openhab.org/user_avatar/community.openhab.org/michael_p/32/66761_2.png) [@michael\_p](https://community.openhab.org/u/michael_p)\
**Post date:** [January 26, 2021, 8:22pm UTC](https://community.openhab.org/t/javascript-and-hsbtype/115521/1 "2021-01-26T20:22:26Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [January 26, 2021, 10:42pm UTC](https://community.openhab.org/t/javascript-and-hsbtype/115521/2 "2021-01-26T22:42:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![michael\_p](https://community.openhab.org/user_avatar/community.openhab.org/michael_p/32/66761_2.png) [@michael\_p](https://community.openhab.org/u/michael_p)\
**Post date:** [January 27, 2021, 10:54am UTC](https://community.openhab.org/t/javascript-and-hsbtype/115521/3 "2021-01-27T10:54:29Z")

</div>

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](https://openhab-scripters.github.io/openhab-helper-libraries/Getting%20Started/Installation.html).

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?

---

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [January 27, 2021, 3:38pm UTC](https://community.openhab.org/t/javascript-and-hsbtype/115521/4 "2021-01-27T15:38:28Z")

</div>

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](https://github.com/openhab-scripters/openhab-helper-libraries) is the official repo for the libraries.

> [@michael\_p](#):
>
> Lastly can i even use the libraries in a GUI Script or are they only supported from file scripts?

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.

> [@michael\_p](#):
>
> I’m wondering if I can contribute to some documentation (which is really lacking tbh.).

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.

> [@\[Wiki\] How to contribute to the openHAB Documentation](https://community.openhab.org/t/wiki-how-to-contribute-to-the-openhab-documentation/111308):
>
> Contributing to the Documentation can be tricky, especially when you don’t have a software/programming background. One reason for this may be way of how we are storing and processing the documentation pages. We do it with a version control system like it is known in software development. This tutorial/wiki aims to lower down the entry hurdle for interested users, who would like to help us improve/fix the documentation. We will cover some facts about our documentation and what we are doing wi…

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.
