Create Dynamic Lighting Scenes

Hi there,

I’m quite new to the platform and have been looking for a way to run a Zigbee HA light through several states automatically at the press of a tile.

For example, I want to have a tile on the app that when I press, my light dims to 5% in 1 second, then dims to 87% in 3 seconds, then 40% in 5 seconds.

Or whatever combinations I feel like. My use case is a product demo. I want to show customers how a product looks across different lighting scenes. I want customers to be able to press one tile and be able to watch the light dimming up and down on a product over particular levels and transition times and see how that affects what the product looks like.

I thought the following code would execute this, but it only seems to execute the last command and my light dims to 40% in 5 seconds.

Does anyone know what might be going wrong or how to achieve what I want to do?

This is my method in the device handler which the tile calls when pressed:

def testing() {
log.debug "dimming to 5% in 1s"
zigbee.command(0x0008, 0x04, “0D”, “1000”)

log.debug "dimming to 87% in 3s"
zigbee.command(0x0008, 0x04, "DD", "3000")

log.debug "dimming to 40% in 5s"
zigbee.command(0x0008, 0x04, "66", "5000")

}

You are close, you just need to return a list of all the commands you want to execute, like this:

def testing() {
    log.debug "dimming to various levels"
    [zigbee.command(0x0008, 0x04, "0D", "1000"),
     zigbee.command(0x0008, 0x04, "DD", "3000"),
     zigbee.command(0x0008, 0x04, "66", "5000")]
}

In Groovy the last line of the function is returned, so in this case it is those three commands with a 2 second delay between them. The 2 second delay is added automatically as part of zigbee.command. Also FYI there is a zigbee.setLevel command that you can use instead of directly sending the Move to Level with On/Off command. The documentation is here http://docs.smartthings.com/en/latest/ref-docs/zigbee-ref.html?highlight=setLevel#zigbee-setlevel. If you do stick with zigbee.command keep in mind that the last argument is in little endian hex, so those values equate to 0x0010 (1.6s), 0x0030 (4.8s) and 0x0050 (8.0s).

1 Like