How to makes lights Flash (code for DTH modification)

dth_lighting
dth_security
dth_alerts

(Bruce) #1

It is possible to add a custom command to either z-wave or zigbee device handlers to make them flash when commanded. Once the custom device handler is created and published, you can edit the device you want to flash to use that device handler. After that, the flash command can be exposed in Rule Machine Create Custom Commands, and used as an action in Rule Machine.

For either type, add this line in the metadata:

command "flash"

For a zigbee device add this code:

def flash() {
	delayBetween ([
    	delayBetween ([	zigbee.on(),
        		zigbee.off()], 1000),
    	delayBetween ([	zigbee.on(),
        		zigbee.off()], 1000),
    	delayBetween ([	zigbee.on(),
        		zigbee.off()], 1000),
                        ], 1000)
}

For a z-wave device add this code:

def flash() {
	delayBetween ([
    	delayBetween ([	zwave.basicV1.basicSet(value: 0xFF).format(),
        		zwave.basicV1.basicSet(value: 0x00).format()], 1000),
	delayBetween ([	zwave.basicV1.basicSet(value: 0xFF).format(),
        	        zwave.basicV1.basicSet(value: 0x00).format()], 1000),
        delayBetween ([	zwave.basicV1.basicSet(value: 0xFF).format(),
        		zwave.basicV1.basicSet(value: 0x00).format()], 1000),
    	zwave.switchBinaryV1.switchBinaryGet().format()], 2000)
}

Capability Flash (~Blink, ~Strobe)
Capability Flash (~Blink, ~Strobe)
New Developer trying small mod to existing code
(Eric) #2

does this create a series of schedule items?


(Bruce) #3

No, it does not. This is done in the device handler through a sequence of delays and commands. Delays are handled differently than things that are scheduled. Most z-wave device handlers use delays, and they all work. So we know that this particular mechanism is more or less OK.


(Bernie H) #4

Am I correct that if I modify the stock DTH that runs local now it will no longer run local?


(Jason) #5

Yes, but if your using rule machine it isn’t running local anyways… unfortunately. …


#6

Hi Bruce,

Thanks for all your work here!

I’m able to select my custom device handler for a Z-Wave Switch. But I don’t see a “Flash” command exposed when I create a custom command.

I also don’t see a “Flash” button when I’m testing the device driver. But the buttons visible there are ones exposed in the Rule Machine custom commands.

Is there something I need to do to add “flash” to the list of custom commands?


(Bruce) #7

You probably failed to add the metadata

command "flash"


#8

That was it. Thanks!