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.