WebThingsIO / gateway

WebThings Gateway
http://webthings.io/gateway
Mozilla Public License 2.0
2.61k stars 333 forks source link

[Snap] Give add-ons access to serial ports #3152

Open benfrancis opened 3 weeks ago

benfrancis commented 3 weeks ago

May require the serial-port/raw-usb interface.

Currently the Zigbee add-on does not work...

STR:

Expected:

Actual:

Logs from /var/snap/webthings-gateway/current.webthings/log/run-app.log:

2024-08-20 19:06:03.296 INFO   : zigbee-adapter: Loading add-on zigbee-adapter from /root/snap/webthings-gateway/x1/.webthings/addons/zigbee-adapter
2024-08-20 19:06:03.879 INFO   : zigbee-adapter: DEBUG config = ''
2024-08-20 19:06:03.886 INFO   : zigbee-adapter: Probing serial ports
2024-08-20 19:06:04.081 INFO   : zigbee-adapter: Serial ports that were found:
2024-08-20 19:06:04.134 ERROR  : zigbee-adapter: Failed to start add-on zigbee-adapter: No Zigbee dongle found
benfrancis commented 3 weeks ago

The same will likely be true for the Z-Wave add-on too, since that also uses a serial connection.

In order to access serial ports, a snap needs access to the serial-port interface. We can request this interface in snapcraft.yaml, but it is usually not connected by default so would require a user to manually connect the interface on the command line. We can request an exception in the snap store but it may not be granted.

As I understand it on Ubuntu Core it also requires serial device paths to be hard coded in a gadget snap, unless using the experimental hotplug support, which is still marked as experimental and therefore can not be enabled by default. This may be a problem because the gateway supports multiple USB dongles.

As I understand it the existing Raspbian image supports hotplug USB devices.