HA on Hyper-V with Z-Wave and Zigbee - It Works!

Hyper-V doesn’t support USB passthrough. But, as of Windows 2016, it does support PCIe device passthrough (using “Discreet Device Assignment” - DDA). So, I tried installing a PCIe expansion card with a couple of USB 3.0 ports, plugged in a Z-Wave stick & passed the card through to a new VM using the standard haos vhdx. It booted right up, found the Z-Wave device & offered to install Z-Wave JS - I let it & it works! Same for a Sonoff ZigBee 3.0 device.
A few pre-requisites:

  • I’m using Windows Server 2022 (DEV machine) - I’m not sure if DDA is supported on Windows 11

  • In the BIOS, I needed to enable SR-IOV (“single-root I/O virtualization”). On mine (ASUS TUF Gaming X570) it was under Advanced | PCI settings

  • In Device Manager, expand “Ports (COM & LPT)” and “Universal Serial Bus controllers” - take a ‘before’ screenshot.

  • In the Hyper-V settings for the HomeAssistant VM, change the ‘Automatic Stop Action’ to ‘Power Off’.

  • Power off, plug in the PCI card, power on & back to Device Manager. Compare with the ‘before’ screenshot, you should have a new COM port a new USB device & a new USB Controller. Right click the new COM port, Properties, Details & Property: Location paths. Value should be something like: PCIROOT(0)#PCI(0102)#PCI(0000)#PCI(0600)#PCI(0000)#USBROOT(0)#USB(3) - take note! Then right click it again & disable. Now find the new USB Device & USB Controller - again check the Location paths for them, looking for mostly matching path info - and disable both of those.

  • Then from an admin powershell (changing the LocationPath & VMname to match yours) :

Dismount-VMHostAssignableDevice -force -LocationPath "PCIROOT(0)#PCI(0102)#PCI(0000)#PCI(0600)#PCI(0000)"

Add-VMAssignableDevice -LocationPath "PCIROOT(0)#PCI(0102)#PCI(0000)#PCI(0600)#PCI(0000)" -VMname HomeAssistant

One thing to look out for, in my case anyway, changing the SR-IOV setting in the BIOS caused all the VMs to lose network connectivity. I had to create a new virtual network switch, check ‘Enable SR-IOV’ and change all the client VMs to use this network.


Some further “observations”…
This process seems to be somewhat “sensitive” to which USB cards you use. The first one I tried - a “FebSmart 2-Ports Superspeed 5Gbps USB 3.0 PCI Express Expansion Card (FS-U2S-Pro)” worked perfectly… for me. But 2 ports was a bit limiting, so I tried a few other 5 & 7 port cards and got all sorts of flakey results. Typically, the device wouldn’t be recognized after a host reboot, the VM wouldn’t find the hardware it needed & would refuse to boot! In the end, I just got a 2nd 2-port card (same one), and everything is great - I have Z-Wave, Zigbee, Blutooth & 1 spare (that I’ve used to initialize ESPHome devices).
For that “VM won’t boot” issue, I found I could delete & recreate the VM definition, keeping the same hard disk file. Then putting back the functioning USB card, going through the disable/dismount/add process again to assign it to the new VM (sometimes, some of the steps were done already). HA would find the different card, but the same USB devices & carry on happily!