Looking for flash () routine

In the Generic Zigbee driver is a flash capability.
I have outlets that have a problem that can't use that driver. So I converted all my outlets to a community outlet driver. However this driver has no flash capability.
I've searched everything I can think of to see the Flash (some call it Identify) feature so I can include it with the community driver I'm using. I have 6 outlets on a long strip at a work table and I want to use this feature! It's not critical of course ...
The outlets identifies itself as:

  • endpointId: 01
  • application: 05
  • endpointId: 01
  • profileId: C05E
  • inClusters: 0000,0003,0004,0005,0006
  • outClusters: 0000
  • model: SA-003-Zigbee
  • manufacturer: eWeLink

Comparing this fingerprint it models on the Sonoff basiczbr3 switch if that helps anyone. I haven't broken one open to see what the chipset is so I can go get the manufactures docs but I'd like to avoid ruining a unit needlessly! Can anyone give me a clue or just outright show me? thanks!

If you were using Hubitat's built-in "Flash" command with that driver, it's likely it was just simulating the effect with repeated on/off commands. That's something you code code into any driver yourself, which sounds like it should be possible since you're working with the code here. (Hubitat has an an example of this in a couple of their public drivers, but it's really nothing special on the Zigbee or Z-Wave side--in these particular drivers.)

But as you note, some devices do have "native" capability for this--but its typical purpose, as the name of the Zigbee cluster you found suggests, is device identification. For a bulb, this could mean blinking/flashing it once or for a few seconds. I have not seen this on any outlets (yet?), and if implemented, I suspect it might be a blink of the LED or something else visible on the outlet, not the entire device turning on and off repeatedly (which I assume is what you really want). I have not seen any examples of this, though someone who knows Zigbee better than I do could probably figure out what to send to try, but again I don't think it's likely to work as you expect for outlets. So...back to the other idea, most likely. :slight_smile:

And on that regard, you really don't need anything built in to the driver to do this; if it's easier, you can do the exact same thing from an app, including a rule--just toggle the device or group at the specified interval. I'm normally not a huge fan of this approach (it generates a lot of Zigbee or Z-Wave traffic, and the smaller the interval, the worse--I wouldn't be surprised if a device missed a command once in a while), but it's the same whether it comes from an app/rule or the driver, so that much wouldn't matter in this case...

1 Like

i was thinking it was a device command built in, but now that you bring up the obvious - turn it off and on... duh! I can do that! I'm guessing thats how Toggle works too...


Yes, "toggle" is not a standard device command, so any app that implements something with that name, like Rule Machine, just reads the current state and sends an "on" or "off" as needed. That being said, "flash" is now a possible standard device command (it was introduced as a "Flash" capability with a flash() command in 2.2.6, formalizing the informal convention that some drivers just happened to all have a command with this name), but standardized or not, the driver can implement it--or choose not to--however it wants, and all the built-in drivers I know of simulate it with what amounts to just on/off. Rare (but not unheard of...except probably not for outlets) is the device that supports some built in "effect" to do this on its own.

Thought I just add, it is possible with plugs at least with the Sonoff S31 Lite Zigbee units I have.

using the generic drivers


If I click on the flash button it actually turns on and off the plug and continues to do so until you either press on or off.
If I misunderstood your original message my apologies, I will go back to my dark corner :joy:

Nope, that's what I meant. :slight_smile: So you might have a device that really does it!

(Whether it's native or simulated by the driver, I don't know, which is more of what I meant, but if it works...)

Hiya. thank you - I poorly explained as I always seem to do, what I mean. I saw the flash ability in the generic driver - and yes. it works great for me too on my eWeLink (and CMARS and Seedan) outlets. however, that generic driver has a flaw, a problem or a design issue that affects me - so I switched to the Ohlalabs outlet driver. Sadly, that community driver doesn't include the functions of Toggle or Flash.

The driver is amazingly great coding - a real professional. I was hoping for a really easy (ie; CHEATING) way to drop a snippet into the driver. I could find nothing.

Update* I just learned how to add my function to the existing array! now to get the flash to loop iterations...

I dug up that there is an actually command for Toggle - I found it on the chip manufacturers website - but I can't figure out how to put it into the code either.
zigbeeCommand(0x006, 0x02)

Hubitat might have a "friendly" way to do this, but using a "raw" Zigbee command will probably work. Maybe something like:

String toggle() {
   if (enableDebug) log.debug "toggle()"
   return "he cmd 0x${device.deviceNetworkId} 0x${device.endpointId} 0x006 0x02 {}"

(You could do def toggle() too, and that's probably what you'll see it lots of code...I'm just into specific typing. :slight_smile: ) I don't do much with Zigbee driver development, however, so someone might have to correct my command format if that's wrong...seems right based on what you provided, though.

Don't forget to add command "toggle" to your definition too if you want to use this as a device command (it's not part of any standard Hubitat capability, and I'm not sure there's much of an advantage to doing this over just sending an on() or off() based on the device's current state, assuming that gets accurately reported back, but it should work if that is right).

For adding a flash() command, it sounds like you may have some idea of where to start. You could look at my Inovelli LZW30-SN (Red Series switch) driver to see how I did it: https://github.com/RMoRobert/Hubitat/blob/master/drivers/Inovelli/Red-Switch-LZW30SN-Advanced.groovy. One thing I'd change now is replace command "flash" with capability "Flash" in the definition (this has been standardized into a capability now; it was not when I wrote that). The key parts to look at are the flash() method that implements this required command, the flashOn() and flashOff() methods that help make this behavior happen (in conjunction with the preference for flash rate), and--just because it seems to be convention--the fact that calling an on() or off() will also stop the flash, the current state of which is tracked in state.flashing (so running one of these commands sets that to false, whereas running flash() sets it to true, besides starting the repeating on/off commands).

Of course, that's a Z-Wave driver, so the biggest difference is that you'll return Zigbee commands instead. You should be able to use whatever you're doing in on() and off(), like something like "he cmd 0x${device.deviceNetworkId} 0x${device.endpointId} 0x006 0x01 {}" for on(). (You might also need to do a rattr with a slight delay after the cmd to get the state back; the driver you're starting with might already be doing this, at least for on/off commands. You may or may not care to do it in between phases of a flash.)

EDIT: I suppose I should mention that the above, of course, is simulating the flash and not relying on the Zigbee identify cluster. That may work for some devices, and if you know the right Zigbee command to send (and the outlet responds), that could certainly be used instead. I just don't know what that would be, or know enough about Zigbee to give you a good guess.

HEy! thanks for that.... honestly I didn't really expect such effort but - this community.. really helps!

Before you answered - I had solved 1/2 my problem. I had successfully figured out the Toggle problem. and honestly it works perfect. Here was my solve:

ArrayList toggle() {
logging("toggle()", 1)
return zigbeeCommand(0x006, 0x02)

After having learned by reading the docs at the manufacturer I did learn that x02 is the command for toggle. Once I learned that, I duplicated the on() and off syntax in the Ohlalalab driver I was butchering.

Today was all about the next problem and honestly I was thinking to just give up. The flash() is harder. much harder. I've been looking at routines in bulbs (the Advanced CT bulb has a great Flash routine), I tried looking at every public driver and just couldn't find the answer.
So - heres the problem - Drivers don't work exactly like an app. When I ran the Flash() I get one iteration. or at least it seems to be one. but I think it's running 60 commands super fast and I only see 1 output. So I dug in and researched delays - I tried runIn, I tried delayBetween, I tried pauseExecution. Nothing would give me the result I expected and I think I'm thinking like a PHP programmer and not a C+ programmer.

Here is the last version I tried before I gave up. The result was an off, then an on - but that was it.
I want it to go off and on, in 1 second intervals for 30 seconds. Be aware, I'm pretty certain I actually crashed my hub with this code.

If you can recommend an answer, I'm all ears!
(And just to repeat - this CRASHED MY HUB - like 2 hrs later.)
List flash() {
def z = 0
state.flashing = true
if (logEnable) log.debug "flash()"
List cmds = []
while (z < 10) {
return delayBetween(cmds,1000)
state.flashing = false

@williams2 sorry about the delayed response - I was just going back through the thread to look for more ideas - I saw your post - but unfortunately the generic drivers (correct me if I'm wrong!) aren't public so I can't go cut and paste or use as a model... I've been trying other things, so far to no avail. @bertabcd1234 sort of got my engine re-reved and his elegant inovelli driver gave me some new hope. Still trying!

If that's an exact copy/paste, your code won't work because you're incrementing z outside your while loop, which is an infinite loop that will probably run until your hub crashes (or it hits some sanity check the sandbox might impose--don't know what they've got going on there). Some solutions, as you probably see now: move z++ inside; rewrite while (z < 10) as while (z++ < 10) rather than manually incrementing it in the loop (remember that ++ after the variable will not increase it until after evaluation); or consider a Groovy-esque way of writing the loop, like 1..10.each { ... }.

If that was a copy/paste error, then other than that, it's just a ton of Zigbee commands to cram into one list, and maybe the hub doesn't like that. (I also have no idea how it handles delays--if it "holds up" anything that might cause a crash later/soon, or if it lets other things run in the meantime.) So, if that wasn't it, I'd suggest re-doing it using a pattern like the one I described in my other post, which is what you'll find in my Inovelli driver. It's modeled after what Hubitat does in their built-in drivers, or at least the ones they've made public, so I figured it's probably not a bad choice. This uses runIn() to effectively create a chain of repeated commands, but the driver goes to sleep in the meantime, and the hub (and Zigbee radio) are for sure free to do other things--not saying they aren't in the other case, just that they certainly would be here.

Wow.... I got it working! I studied your flash routine in the Inovelli. At first it wouldn't fly - when I issued 'return zigbeeCommand(0x006, 0x01)' I got nothing. BUT. once i changed the declaration from String to ArrayList so it was in the same array as the on/off functions it worked!!! I also played a bit with the toggling of the flashing state - so I could push the button and it would go on, then off... Man. that was harsh. I really need to go back to school! Thank you!

1 Like

So, some of that you can avoid by just using def and letting Groovy figure out the types for you, but I like to be specific. :slight_smile: My on() and off() methods just return a single command as a String, but zigbee.command() returns a List (possibly an ArrayList, but I'm not that specific--and you may not want to be in case the implementation details change), so that's why you'd need that there.

I'm also not a huge fan of flash that is simulated in the driver, despite the fact that I did it in the one above (it's again nothing you couldn't do with an app, and likely in a more reliable way if you have multiple devices and they're in a Zigbee group), but...it can work. Ha.