Command Sent To ZigBee Device From Script Not Working

  • Platform information:
    • Hardware: x86_64 Atom/4GB/20GB
    • OS: Ubuntu Linux 20.04
    • Java Runtime Environment: OpenJDK 11.0.10
    • openHAB version: 3.1.0
  • Issue of the topic: Sending updates from a rule script to a ZigBee Color bulb does not cause any change in the bulb state

I have the following script (and many variations besides) which does not actually allow me to toggle between Black(OFF) and Red.

import org.openhab.core.library.types.*
import static org.openhab.core.model.script.actions.BusEvent.*

import org.slf4j.LoggerFactory

def logger = LoggerFactory.getLogger("org.openhab.core.automation.examples")

def hsb = itemRegistry.getItem("DevenColorBulb_Color").getStateAs(HSBType.class).toString()

logger.info("${hsb.getClass().getCanonicalName()}: ${hsb}")

if (!hsb.contentEquals("0,100,100")) {
  logger.info("Sending: Red")
  postUpdate("DevenColorBulb_Color", "0,100,100")
} else {
  logger.info("Sending: Black")
  postUpdate("DevenColorBulb_Color", "0,100,0")
}

I can see from the log output that the correct commands are being sent, but the bulb almost never changes. The only time it DOES seem to change is if I manually change the color from habpanel and then run the rule script.

I have many similar rules for Z-Wave devices (Switches and Dimmers) and they work reliably. What am I doing wrong here?

Thanks in advance for any help!

Your post talks about sending command, but your code does postUpdate.
These are different functions for a reason.