You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading my production system to 4.1 I have run into an issue related to QuantityType and JavaScript Scripting.
I don't know if the issue is in openhab-js or in the Energi Data Service thing action. The thing action code was not changed recently, so if the problem lies here, it's probably still related to openhab-js changes, perhaps an existing bug in the thing action being exposed by stricter checks on openhab-js side. Anyway, I hope you'll be able to assist figuring out the culprit.
Expected Behavior
No error, the call should produce a correct result like in 4.0.
2023-12-23 16:01:15.535 [ERROR] [enhab.automation.script.file.test.js] - Failed to execute rule Test-JavaScript-8553ef2d-9a4e-484f-ba06-81ada6e26649: TypeError: invokeMember (calculatePrice) on org.openhab.binding.energidataservice.internal.action.EnergiDataServiceActions@11d3737 failed due to: Cannot convert '[object Object]'(language: JavaScript, type: A) to Java type 'org.openhab.core.library.types.QuantityType': Unsupported target type.: TypeError: invokeMember (calculatePrice) on org.openhab.binding.energidataservice.internal.action.EnergiDataServiceActions@11d3737 failed due to: Cannot convert '[object Object]'(language: JavaScript, type: A) to Java type 'org.openhab.core.library.types.QuantityType': Unsupported target type.
at <program> (test.js:18)
at _run (@openhab-globals.js:2)
at execute (@openhab-globals.js:2)
at execute (@openhab-globals.js:2)
2023-12-23 16:01:15.541 [ERROR] [e.automation.internal.RuleEngineImpl] - Failed to execute rule 'Test-JavaScript-8553ef2d-9a4e-484f-ba06-81ada6e26649': Failed to execute action: 1(Error: Failed to execute rule Test-JavaScript-8553ef2d-9a4e-484f-ba06-81ada6e26649: TypeError: invokeMember (calculatePrice) on org.openhab.binding.energidataservice.internal.action.EnergiDataServiceActions@11d3737 failed due to: Cannot convert '[object Object]'(language: JavaScript, type: A) to Java type 'org.openhab.core.library.types.QuantityType': Unsupported target type.: TypeError: invokeMember (calculatePrice) on org.openhab.binding.energidataservice.internal.action.EnergiDataServiceActions@11d3737 failed due to: Cannot convert '[object Object]'(language: JavaScript, type: A) to Java type 'org.openhab.core.library.types.QuantityType': Unsupported target type.
at <program> (test.js:18)
at _run (@openhab-globals.js:2)
at execute (@openhab-globals.js:2)
at execute (@openhab-globals.js:2))
The issue is in the Addon code, but it is caused by a recent change to openhab-js, that was required to fix an issue.
I had to rename a private property, which broke the conversion inside the add-on.
As a work-around, you can use Quantity(…).rawQtyType, but I’ve already created a PR to fix that: openhab/openhab-addons#16106
After upgrading my production system to 4.1 I have run into an issue related to
QuantityType
and JavaScript Scripting.I don't know if the issue is in openhab-js or in the Energi Data Service thing action. The thing action code was not changed recently, so if the problem lies here, it's probably still related to openhab-js changes, perhaps an existing bug in the thing action being exposed by stricter checks on openhab-js side. Anyway, I hope you'll be able to assist figuring out the culprit.
Expected Behavior
No error, the call should produce a correct result like in 4.0.
Current Behavior
This rule code:
Results in:
The thing action code is here:
https://github.com/openhab/openhab-addons/blob/dc187c9eec267cd4c6fa57d883db48b281f8fad8/bundles/org.openhab.binding.energidataservice/src/main/java/org/openhab/binding/energidataservice/internal/action/EnergiDataServiceActions.java#L138-L151
Third parameter, which I suspect is related to the issue, is defined as:
Possible Solution
Currently none.
Steps to Reproduce
Context
Unfortunately most EDS thing actions are broken, thus automations for optimizing electricity usage.
Your Environment
The text was updated successfully, but these errors were encountered: