OH3: Script to operate Hue lightstrip

  • Platform information: OH3
    • Hardware: RPi3
    • OS: openhabian

Hi there, I am trying to write a script for a Phillips Hue light strip. Trying to turn it on, change its colour for a period of time and turn it off. Driven manually the lights trip works fine.

The below turns the light strip on, but does not change the colour to 12,100,51, instead leaving it in its last colour state and then turns the light strip off.

Is there a different process I should us to set the colour/brightness?

var logger = Java.type('org.slf4j.LoggerFactory').getLogger('org.openhab.rule.' + ctx.ruleUID); 
var ScriptExecution = Java.type("org.openhab.core.model.script.actions.ScriptExecution"); 
var ZonedDateTime   = Java.type("java.time.ZonedDateTime"); 
var test_Timer1;
if (itemRegistry.getItem('Test_Sw').getState() == 'ON')  
  logger.info('Hue - Lightstrip *** RED')
  events.sendCommand('Huelightstrip_Color', ON);
  events.postUpdate('Huelightstrip_Color', "12,100,51"); 
  if (this.test_Timer1 !== undefined) { 
    this.test_Timer1 = undefined; 

if (itemRegistry.getItem('Test_Sw').getState() == 'ON')  
  this.test_Timer1 = ScriptExecution.createTimer(ZonedDateTime.now().plusSeconds(20), function() 
  logger.info('Hue - Lightstrip *** OFF ***'); 
  events.sendCommand('Huelightstrip_Color', OFF);

Kind regards

postUpdate(xx) updates the state of an Item only. That’s internal to openHAB.
If you want a binding to so something with that, like send it to device, you would need to use sendCommand instead.

Thanks for your reply. That was it.