Troubele with Binding for API v2 "Rule Actions -> dynamicCommand"

Hello to all,

Hello everyone,

I’m trying to execute a dynamic command to adjust the brightness of a Hue device using OpenHAB 4.2.2 on my Raspberry Pi.

I’ve tried two approaches:

Approach 1: Using a Shortened Thing UID

    val hueActions = getActions("hue","hue:device:001788fffe2e2524:3")
    hueActions.dynamicCommand("brightness", new PercentType(99), Long.valueOf(10000)) 

This resulted in the following error:

2024-11-01 21:35:58.427 [WARN ] [e.internal.handler.Clip2ThingHandler] - Dynamics command '99' for thing 'hue:device:001788fffe2e2524:3', channel 'brightness' and duration'10000 ms' failed.
2024-11-01 21:35:58.428 [DEBUG] [.hue.internal.action.DynamicsActions] - Dynamic command '99' sent to channelId 'brightness' with duration 10000ms.

Approach 2: Using the Full Thing UID

val hueActions = getActions("hue","hue:device:001788fffe2e2524:64089ea9-f9a8-4d1b-9806-c1c876149c1b")
    hueActions.dynamicCommand("brightness", new PercentType(99), Long.valueOf(10000)) 

This resulted in the following error:

2024-11-01 21:47:47.028 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'hue-2' failed: Cannot invoke "org.openhab.binding.hue.internal.action.DynamicsActions.dynamicCommand(String, org.openhab.core.types.Command, java.lang.Long)" because "actions" is null in hue

I’m not sure what I’m doing wrong. Any help would be greatly appreciated.

Approach 2 is the correct syntax.
Does your thing actually have a ‘brightness’ channel? If your thing is a color lamp, then it probably has a ‘color’ channel but no ‘brightness’. In that case you send the PercentType command to that channel. Or you can use the ‘dimming-only’ channel.

Thank you very much for your help, it works now.
Some things have become clearer to me now and I’m trying to summarize them. If something is wrong, please comment.

In my opinion both approaches are needed.

Approach 1 for device combined with a color channel


Here the color channel

val hueActions = getActions("hue","hue:device:001788fffe2e2524:3")
val hueActions.dynamicCommand("color", new PercentType(99), Long.valueOf(20000))

Approach 2 for room combined with a brightness channel


Here the brightness channel.

val hueActions = getActions("hue","hue:room:001788fffe2e2524:229990ef-0e91-442c-9db7-31691452ccd9")
hueActions.dynamicCommand("scene", new StringType("Tropendämmerung"), Long.valueOf(20000))
hueActions.dynamicCommand("brightness", new PercentType(100), Long.valueOf(20000)) 

Scenes also work with the name/string from OH here the screenshot:

Both room/zone and device things have a variable number of channels. See below. And (obviously) you cannot send commands (neither direct commands nor dynamic commands) to a channel that does not exist in the thing.

  1. Device things. If the device is of type ‘light’ then it may or may not support the following channels depending on the model of light. And if the device is a sensor (motion, light level, contact, temperature) or a button then it will NOT have any of these channels (but rather some channels reflecting the device’s capabilities).
  • If it IS a color light it has a color channel
  • If it supports color temperature it has a color temperature channel
  • If it is NOT a color light but IS dimmable it has a brightness channel
  • If it is NEITHER a color light NOR dimmable it has an on/off channel
  • If it supports effects then it has an effect channel
  • If it supports alerts then it has an alert channel
  • Depending on the above, it may also have (advanced) color_xy_only, dimming_only, or on_off_only channels
  1. Room/zone things. May or may not support the following channels depending on the lights which are members of the room/zone
  • If any of the member lights are dimmable it has a brightness channel
  • If any of the member lights are switchable it has an on/off channel
  • If it has any scenes defined it has a scenes channel