Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[jsscripting] Extend mapping of openhab-js classes to native openHAB counterparts #14335

Merged
merged 3 commits into from
Feb 12, 2023

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Feb 4, 2023

Addon part of openhab/openhab-js#98.

Description

This PR extends the target type mapping inside the JS Scripting addon to also translate the following openhab-js classes to their native openHAB Java counterparts when passing to Java methods:

  • openhab-js Item -> org.openhab.core.items.Item
  • openhab-js Quantity -> org.openhab.core.library.types.QuantityType

Regarding the updated bnd file: I hope I did the right (if I understood the docs correctly I did), but would be nice if one could have a look and verify that it is correct what I did.

Testing

Use the following script to test:

// Check JS-Item -> openHAB Item translation
actions.BusEvent.sendCommand(items.Temperature, "0 °C")

// Check JS-Quantity -> openHAB QuantityType translation
var QuantityType = Java.type('org.openhab.core.library.types.QuantityType')
QuantityType.valueOf('50 cm').add(Quantity('5 m'))

... or trust me given the simplicity of the code when comparing to the existing and well-working code.

…arts

Related to openhab/openhab-js#98.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
@florian-h05 florian-h05 added enhancement An enhancement or new feature for an existing add-on work in progress A PR that is not yet ready to be merged labels Feb 4, 2023
@florian-h05 florian-h05 changed the title [WIP] [jsscripting] Extend mapping openhab-js classes -> native openHAB counterparts [jsscripting] Extend mapping of openhab-js classes to native openHAB counterparts Feb 5, 2023
@florian-h05 florian-h05 removed the work in progress A PR that is not yet ready to be merged label Feb 5, 2023
@florian-h05
Copy link
Contributor Author

@jlaur Can you please review this?

@jlaur
Copy link
Contributor

jlaur commented Feb 9, 2023

@florian-h05 - I'm also not confident with bnd files, perhaps another @openhab/add-ons-maintainers could have a look?

@florian-h05
Copy link
Contributor Author

@digitaldan Are you confident with bnd files?

@digitaldan
Copy link
Contributor

Are you confident with bnd files?

No, although the changes look pretty straight forward to me

Copy link
Member

@wborn wborn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@wborn wborn merged commit d2db49f into openhab:main Feb 12, 2023
@wborn wborn added this to the 4.0 milestone Feb 12, 2023
@florian-h05 florian-h05 deleted the jsscripting-type-mapping branch February 12, 2023 12:12
florian-h05 added a commit to florian-h05/openhab-js that referenced this pull request Feb 14, 2023
Reference openhab/openhab-addons#14335.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
SMHRambo pushed a commit to SMHRambo/openhab-addons that referenced this pull request Feb 14, 2023
…counterparts (openhab#14335)

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Feb 28, 2023
…counterparts (openhab#14335)

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
renescherer pushed a commit to renescherer/openhab-addons that referenced this pull request Mar 23, 2023
…counterparts (openhab#14335)

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
FordPrfkt pushed a commit to FordPrfkt/openhab-addons that referenced this pull request Apr 20, 2023
…counterparts (openhab#14335)

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants