This article describes how I rescued my Z-Wave light switches after my Home Assistant server failed and I bricked my Z-Wave USB controller. [Reddit Thread](https://www.reddit.com/r/smarthome/comments/1f3kea7/how_i_made_a_mobile_zwave_exclusion_device_to/) ## Background My smart home setup consists of a Home Assistant (HA) server, an [Aeotech Z-Stick 7](https://aeotec.com/products/aeotec-z-stick-7/) Z-Wave USB controller, and a bunch of[ GE Enbrighten dimmer switches](https://www.amazon.com/gp/product/B07RRD92T8) (model #46203). About six months ago, the HA server completely failed and I was not able to restore from backups. While trying to rebuild my HA setup from scratch, I also tried to upgrade the firmware on my Z-Stick and completely bricked it. Oops. When my new Z-Stick came in the mail, I discovered all my existing switches still thought they were attached to the old, now dead, Z-Wave controller and I could not get them to pair to the new controller. I spent hours googling how to reset the switches to no avail. The paper instructions that came with them said I could trigger a factory reset by pressing on the up rocker 3 times and then the down rocker 3 times. This would cause the status light to blink, but I still could not pair them to my new controller. I also tried to put the new Z-Wave controller into exclusion mode and exclude the switches from the old network that way, but many of the switches were too far away from the HA server and exclusion didn't seem to work.^[For those unfamiliar with Z-Wave, this is how you get a Z-Wave device to disassociate itself from an existing network. You put a controller (any controller, it doesn't have to be the original controller) in exclusion mode, and then press something on the device (this part is device specific and up to the manufacturer).] My HA server was a Mac Mini in my office, and the switches were attached to the wall, so I couldn't move either of them closer to the other. I found many [posts](https://www.reddit.com/r/homeassistant/comments/so3qvp/any_other_tricks_to_get_ge_jasco_z_wave_switches/) [on](https://community.smartthings.com/t/how-to-exclude-include-ge-z-wave-switch-which-can-not-be-factory-reset-the-switch-zw4001/164497) various smart home forums with people in similar situations. Some folks were so desperate they eventually just completely replaced the switches. I can't imagine how many thousands of dollars in Enbrighten switches have ended up in landfills due to this issue. At this point I was so frustrated I decided to just live with a dumb home for a while. ## Making a Mobile Z-Wave Network Excluder Six months later, I was ready to start troubleshooting the issue again. I found a post on a smart home forum from someone who solved this issue by using their [Aeotech Z-Stick Gen5](https://store.aeotec.com/products/z-stick-gen5-zw090). Apparently this version of the stick contains a rechargeable battery, so you can walk around your house with only the stick (not plugged into a computer), activate exclusion mode on it while standing right next to the switch, and get the switch to exclude itself from the dead network. This highlights one very important piece of information: to exclude a Z-Wave device, *you do not need the original Z-Wave controller.* Any controller will do. When I first started troubleshooting this, I did not know that. Anyway, this solution seemed promising, but I wasn't sure I wanted to invest another $59 into trying to fix these switches. If I was going to spend more money, I was tempted to just go all-out and replace them with Lutron Caseta's after having such a bad experience. So I didn't have a battery powered Z-Wave stick, but I did have a laptop. One idea I had was to install HA on the laptop, plug the Z-Wave controller stick into the laptop, put the stick into exclusion mode, and walk around with the laptop. I started going down this path, but then wondered if I could do it without HA? After all, HA uses [Z-Wave JS](https://github.com/zwave-js). I'm a software developer. Why not just use Z-Wave JS directly? I installed Z-Wave JS (`npm i zwave-js`) and plugged the Z-Stick 7 into my laptop. It immediately showed up as a serial device: ``` $ ll /dev/tty.usb* crw-rw-rw- 1 root wheel 0x9000004 Aug 28 09:36 /dev/tty.usbserial-10 ``` Now all I had to do was write a program that put the controller in exclusion mode: ```js const { Driver, ExclusionStrategy } = require("zwave-js"); async function main() { const driver = new Driver("/dev/tty.usbserial-10"); // Listen for the driver ready event before doing anything with the driver driver.once("driver ready", () => { console.log("Z-Wave driver started"); // Put the controller in exclusion mode driver.controller.beginExclusion(ExclusionStrategy.Unprovision).then(r => { console.log(`Result: ${r}`); }); console.log("Controller is now in exclusion mode"); console.log("You can now exclude Z-Wave devices"); driver.controller.once("exclusion started", () => { console.log("Exclusion started"); }); // Once exclusion is stopped, quit driver.controller.once("exclusion stopped", () => { console.log("Exclusion stopped, destroying driver instance"); driver.destroy(); }); }); await driver.start(); } main().catch(console.error); ``` The program turned out to be simple. Just connect to the Z-Stick, put it in exclusion mode, wait for the exclusion to happen, and then exit once exclusion was finished. So I started the program, walked up to a switch, pressed the down rocker, and among a bunch of other messages I saw: ``` Z-Wave driver started Controller is now in exclusion mode You can now exclude Z-Wave devices <snip> 10:40:46.069 DRIVER « [REQ] [RemoveNodeFromNetwork] payload: 0x01020000 10:40:46.070 DRIVER handling request RemoveNodeFromNetwork (75) 10:40:46.070 DRIVER 1 handler registered! 10:40:46.070 DRIVER invoking handler #0 10:40:46.071 CNTRLR handling remove node request (status = NodeFound) 10:40:46.343 SERIAL « 0x0119004b01030512041101000000000000000000000000000000ac (27 bytes) 10:40:46.343 SERIAL » [ACK] (0x06) 10:40:46.344 DRIVER « [REQ] [RemoveNodeFromNetwork] payload: 0x01030512041101000000000000000000000000000000 10:40:46.344 DRIVER handling request RemoveNodeFromNetwork (75) 10:40:46.344 DRIVER 1 handler registered! 10:40:46.344 DRIVER invoking handler #0 10:40:46.344 CNTRLR handling remove node request (status = RemovingSlave) 10:40:46.344 DRIVER the message was handled 10:40:46.349 SERIAL « 0x0119004b01060512041101000000000000000000000000000000a9 (27 bytes) 10:40:46.349 SERIAL » [ACK] (0x06) 10:40:46.349 DRIVER « [REQ] [RemoveNodeFromNetwork] payload: 0x01060512041101000000000000000000000000000000 10:40:46.349 DRIVER handling request RemoveNodeFromNetwork (75) 10:40:46.349 DRIVER 1 handler registered! 10:40:46.349 DRIVER invoking handler #0 10:40:46.349 CNTRLR handling remove node request (status = Done) 10:40:48.424 SERIAL « 0x011800a9040101bb007f7f7f7f7f01010700000000020700008c (26 bytes) 10:40:48.425 SERIAL » [ACK] (0x06) 10:40:48.432 DRIVER » [REQ] [RemoveNodeFromNetwork] payload: 0xc500 10:40:48.436 SERIAL « [ACK] (0x06) 10:40:48.438 CNTRLR the exclusion process was stopped Exclusion stopped, destroying driver instance 10:40:48.439 DRIVER destroying driver instance... 10:40:48.439 CNTRLR Node 5 was removed 10:40:48.441 DRIVER the message was handled 10:40:48.441 DRIVER all queues idle 10:40:48.496 DRIVER driver instance destroyed ``` Bingo! It looked like it worked. Or did it? When I first installed the switches, the status LED on them would blink until they were paired (or timed out). After performing the exclusion, the status LED was still a solid blue. I was convinced it didn't work, and I was ready to order $2k in new Caseta switches, but I decided I might as will try to pair them to HA. So I put the USB stick back in the HA server and went through the Add Device routine. And eureka it worked! After performing this on all the switches in my house, I'm back to having a working smart home. ## Short Version 1. Set up a node environment on a laptop. 2. Install Z-Wave JS: `npm i zwave-js` 3. Copy the script above, replacing `/dev/tty.usbserial-10` with the path to the Z-Wave USB dongle. - On Mac, you can run `ls -la /dev/tty.usb*` to list all USB serial devices. Run this before plugging in, and after, and whichever is new is the Z-Wave dongle. 4. Run the script: `node exclusion.js` 5. Walk up to a switch and press the down rocker. 6. Wait for the script to exit, and watch the output to verify the exclusion was successful. 7. Put the Z-Wave USB dongle back into your HA server. 8. Add a new Z-Wave device. 9. Press the down rocker on the switch to trigger inclusion. 10. Put the switches PIN number into HA when prompted. 11. You're back in business baby.