HASSIO in VM on QNAP - Conbee 2 keeps disconnecting

Hello,
I’ve managed to install Home Assistant in VM on QNAP following the topic My way to install HASSIO on QNAP NAS.

But I have problem with Conbee 2. It keeps disconnecting from VM from time to time.

Conbee is plugged into UNITEK Y-2160 USB 2 hub which I’ve plugged to QNAP USB 3 port (no USB 2 ports in my QNAP). I’ve also tried to connect Conbee directly to QNAP with no luck. USB 3 port may be root cause of my problem, but I’ve read on some Polish forum that people are having the same problem with USB 2 ports.

I’m waiting for a USB extension cable I’ve ordered to check if that resolve the issue. I’m also planning to ask QNAP directly if they can help, but one guy from Polish forum has already done that. QNAP replied that he should buy some expensive USB extension card.

I’ve written an automation that detects if Conbee disconnects from VM and attach it again. But it requires paswordless ssh access from VM to QNAP which is not very safe. So if anyone has an idea how to solve the disconnection issue that would be great.

What was your resolution / setup in the end? Or the problem went away?

I’ve created na automation that is triggered when when device disapears. First of all I’ve added folder_watcher in my configuration.yaml:

folder_watcher:
  - folder: /dev
    patterns:
      - "/dev/serial/by-id/usb-dresden_elektronik_ingenieurtechnik_GmbH_ConBee_II_DE2405513-if00"

Then I’ve added an automation with trigger:

platform: event
event_type: folder_watcher
event_data:
  event_type: deleted

and action:

service: shell_command.reconnect_conbee

shell_command.reconnect_conbee:
reconnect_conbee script:

#!/bin/bash

{
date
ssh -i /config/shell/id_rsa -o 'StrictHostKeyChecking=no' admin@[YOUR-QNAP-IP] << EOF
    /QVS/usr/bin/virsh list
    /QVS/usr/bin/virsh detach-device 158876ee-1526-41d2-bd09-ef16c174a2af  --file /share/CACHEDEV1_DATA/config/conbee2.xml
    /QVS/usr/bin/virsh attach-device 158876ee-1526-41d2-bd09-ef16c174a2af  --file /share/CACHEDEV1_DATA/config/conbee2.xml
EOF
} &>>/config/shell/reconnect_conbee.log`

File conbee2.xml:

<hostdev mode='subsystem' type='usb' managed='yes'>
	<source>
		<vendor id='0x1cf1'/>
		<product id='0x0030'/>
	</source>
</hostdev>

158876ee-1526-41d2-bd09-ef16c174a2af should be replaced with your VM id, you can get it using /QVS/usr/bin/virsh list on qnap

1 Like

I just wanted to thank you @Mateusz_Kielar for this excellent walk through. I have had enormous trouble with my Conbee2 Stick disconnecting after I restarted Home Assistant on my Qnap. I can’t count the hours I spent googling to no avail on how to fix this until I came along your post. Thanks to you, I finally have a working solution. I am so happy!!!

Just to add, I had to add:

  allowlist_external_dirs:
    - "/dev"

to my homeassistant: block in my configuration.yaml in order to get the folder_watcher working.

Just for me to stay tuned on this one. I have been working with HA as VM on a QNAP install with Conbee 2 attached to it for a few months without any issues. I know this sounds silly but since I moved places I’m having these issues as well. Every reboot I loose connection to the USB drive. Thanks for the workaround. I`ll try this as well.