jwiseman
(Mr. Wiseman (OH 4.3.0 Snapshot on Pi4))
1
OH 4.3.0 code in DSL using HUE APIv2 binding trying to implement fading of the brightness channel on a room.
var String zKitchen = "hue:room:001788fffeb43df8:a6c9bd6d-0b27-4dab-b112-0146b35fecd3"
val hueActionsKitchen = getActions("hue",zKitchen)
hueActionsKitchen.dynamicCommand("brightness", new PercentType(100), new Long.valueOf(20000))
I cannot figure out why I’m getting this error below.
2025-02-21 22:00:59.833 [ERROR] [cript.internal.handler.AbstractScriptModuleHandler] - Script execution of rule with UID 'default-54' failed: An error occurred during the script execution: Cannot invoke "org.eclipse.xtext.common.types.JvmType.eIsProxy()" because "type" is null in default
jwiseman
(Mr. Wiseman (OH 4.3.0 Snapshot on Pi4))
6
I have spent at least 8 hours on this and I’m closer with No errors now, but the fading isn’t working still, it just does 100% brightness immediately.
Here’s the log trace:
2025-02-22 17:59:42.449 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'HUERoomLoft_Dynamics' received command 10 s
2025-02-22 17:59:42.451 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'HUERoomLoft_Brightness' received command 100
2025-02-22 17:59:42.452 [INFO ] [openhab.event.ItemStatePredictedEvent ] - Item 'HUERoomLoft_Dynamics' predicted to become 10 s
2025-02-22 17:59:42.454 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HUERoomLoft_Dynamics' changed from 0 s to 10 s
2025-02-22 17:59:42.456 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'BookShelf_Color' received command 0,0,100
2025-02-22 17:59:42.458 [INFO ] [openhab.event.ItemStatePredictedEvent ] - Item 'HUERoomLoft_Brightness' predicted to become 100
2025-02-22 17:59:42.461 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HUERoomLoft_Brightness' changed from 0 to 100
2025-02-22 17:59:42.566 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'BookShelf_Switch' changed from OFF to ON
2025-02-22 17:59:42.570 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'BookShelf_Color' changed from 217.789,0.20800,0 to 217.789,0.20800,100
2025-02-22 17:59:52.493 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HUERoomLoft_Dynamics' changed from 10 s to 0 s
Here’s the rule:
var HSBType Redlight = new HSBType(new DecimalType(7), new PercentType(100), new PercentType(100)) // Scarlet Red
HUERoomLoft_Dynamics.sendCommand('10 s')
HUERoomLoft_Brightness.sendCommand(100)
BookShelf_Color.sendCommand(Redlight)
My color lights do NOT have a brightness channel, but the room does which references the color:dimmer channel. I have also tried the dimmer only channel but that didn’t work either.
I have tried the dynamics channel both on the device and room level with same results
I have tried setting the color before and after the routine block, same results
I tried a sleep(1000) between Brightness and Color commands and that didn’t work.
My hunch is, when I send the color value HUE ignores the dynamic brightness task and just turns that color on. Hence the dynamics log going from 100 to 0 immediately.
Do I need to set my last HSBType value to 0 vs. 100 so its brightness channel increases it?
You can only amalgamate a dynamics command with one single subsequent command. So in your rule the third command will be executed immediately and override the prior two dynamics combo commands.
For your color lights the B part of the HSB is the brightness. So to dynamically dim up such a lamp ypu need to send a three command sequence as follows…
send HS0 set the initial Hue and Saturation and initial Brightness zero
Dynamics ‘10 s’
send HSB set the target Hue and Saturation and target Brightness
When you issue such dynamics combo commands please look at the actual physical status of the lamp. i.e. do not just look at the App or OH UI. Reason is that after a dynamics combo command the first response of the Bridge is to show the target state immediately , and then it shows a series of states that reflect stages on the real transition. By contrast the actual lamp does actually follow the transition as programmed.
Please see the recent PR below…
jwiseman
(Mr. Wiseman (OH 4.3.0 Snapshot on Pi4))
8
@AndrewFG, thank you for taking the time to help me debug this. I couldn’t find any documentation about how to do this correctly and your help was invaluable.
Here’s the working solution for me:
var HSBType Whitelight = new HSBType(new DecimalType(0), new PercentType(0), new PercentType(100)) // White - ON Brightness
var HSBType WhitelightOFF = new HSBType(new DecimalType(0), new PercentType(0), new PercentType(0)) // White - OFF Brightness
// 1 light
BookShelf_Color.sendCommand(WhitelightOFF)
Thread::sleep(1000)
BookShelf_Dynamics.sendCommand('10 s')
BookShelf_Color.sendCommand(Whitelight)
// Group of 3 lights
gKitchen_Color.sendCommand(WhitelightOFF)
Thread::sleep(1000)
gKitchen_Dynamics.sendCommand('10 s')
Thread::sleep(1000)
gKitchen_Color.sendCommand(Whitelight)
I did try to get it working at the ROOM level but that didn’t work. It’s working at the DEVICE level now.