Question is: Do you have the Hue API v1 or v2?
If Hue API v1, the action fadinglightcommand should work as it did in openHAB3
If Hue API v2, the action noe is named dynamicCommand.
My next issue was the Long problem you were having (ReferenceError: âLongâ is not defined). I tried Long.valueOf but still get the same error. The code I am using is:
var runtime = require(â@runtimeâ);
hueActions.dynamicCommand(âbrightnessâ, new runtime.PercentType(50), new Long.valueOf(10000))
Thank you for taking the time to post. Iâm still receiving the same error âReferenceError: âLongâ is not definedâ. Perhaps because iâm using âECMAScript (ECMAScript 262 Edition 11)â. Iâll investigate further.
I updated it with the new âdynamicCommandâ and the tip from Rich Koshak regarding the PercentType.
slots:
code:
- component: BlockCodeTemplate
config:
template: >
var runtime = require('@runtime');
{{utility:things}}.getActions('hue',{{input:THING_ID}}).dynamicCommand('brightness', new runtime.PercentType({{input:BRIGHTNESS}}), Long.valueOf({{input:FADING_TIME}}));
Itâs the same error:
2023-08-29 23:41:05.913 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID '3aa6c5980f' failed: org.graalvm.polyglot.PolyglotException: ReferenceError: "Long" is not defined
I solved the ââLongâ is not definedâ by using âNumberâ instead of Long:
var runtime = require(â@runtimeâ);
var hueActions = actions.get(âhueâ, âhue:zone:HueHub1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxâ);
hueActions.dynamicCommand(âbrightnessâ, new runtime.PercentType(100), Number(20000))
Yes. I will do that. @bratmanii can you confirm that Long.valueOf() definitely does work for you? And/or @Wtfgw can you confirm that Number() does also (and/or) work? And if both do work, which do you suggest is the most preferable form for ease of user understanding?
Yes the Number() does work for me. Looks like Matthew is using DSL rules which is why Long.valueOf() is working for him, while I am using ECMAScript (ECMAScript 262 Edition 11), so I guess it is what you are most comfortable with.