esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
294 stars 37 forks source link

esphome interfering with zigbee2mqtt USB #5883

Closed JamieMagee closed 1 month ago

JamieMagee commented 5 months ago

The problem

I've been periodically seeing the error Resource temporarily unavailable Cannot lock port in my zigbee2mqtt logs. It's a common enough issue that zigbee2mqtt have created an FAQ about it ^1.

So I created some audit rules to find out what was accessing my Zigbee USB stick:

$ sudo auditctl -l
-w /dev/ttyUSB0 -p rwxa
-w /dev/serial/by-id/usb-Nabu_Casa_SkyConnect_v1.0_a61ce607b596ed11b11cc498a7669f5d-if00-port0 -p rwxa

It turned out to be esphome

$ sudo ausearch --file /dev/serial/by-id/usb-Nabu_Casa_SkyConnect_v1.0_a61ce607b596ed11b11cc498a7669f5d-if00-port0
time->Tue Jun  4 15:21:54 2024
type=PROCTITLE msg=audit(1717539714.705:1388): proctitle=2F6E69782F73746F72652F637A6C697A6D7235646D707869377973716B6E7879733832373736686C64676B2D707974686F6E332D332E31312E392F62696E2F707974686F6E332E3131002F6E69782F73746F72652F6D6377346230346E6461346D70306C766E36797062663470356363796C6431772D657370686F6D652D3230
type=PATH msg=audit(1717539714.705:1388): item=0 name="/dev/serial/by-id/usb-Nabu_Casa_SkyConnect_v1.0_a61ce607b596ed11b11cc498a7669f5d-if00-port0" inode=549 dev=00:05 mode=0120777 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL cap_fp=0 cap_fi=0 cap_fe=0 cap_fver=0 cap_frootid=0
type=CWD msg=audit(1717539714.705:1388): cwd="/var/lib/private/esphome"
type=SYSCALL msg=audit(1717539714.705:1388): arch=c00000b7 syscall=78 success=yes exit=13 a0=ffffffffffffff9c a1=7f95796ed0 a2=7f9575ce90 a3=1000 items=1 ppid=1 pid=1030 auid=4294967295 uid=64911 gid=64911 euid=64911 suid=64911 fsuid=64911 egid=64911 sgid=64911 fsgid=64911 tty=(none) ses=4294967295 comm=".esphome-wrappe" exe="/nix/store/czlizmr5dmpxi7ysqknxys82776hldgk-python3-3.11.9/bin/python3.11" key=(null)

Is there any way to prevent esphome from accessing this specific device? Or disable USB access entirely?

Which version of ESPHome has the issue?

2024.5.4

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

2024.5.5

What platform are you using?

ESP32

Board

No response

Component causing the issue

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

No response

JamieMagee commented 5 months ago

For anyone who has the same issue, I resolved it by using DevicePolicy and DeviceAllow with systemd.

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.