openhab / openhabian

openHABian - empowering the smart home, for Raspberry Pi and Debian systems
https://community.openhab.org/t/13379
ISC License
820 stars 251 forks source link

zigbee2mqtt won't start frontend ;invalid user: ‘zigbee2mqtt:openhabian’ #1673

Closed MarijnO closed 2 years ago

MarijnO commented 2 years ago

Issue information:

I tried installing zigbee2mqtt but can't access the frontend on my_ip:8081

zigbee2mqtt is runnig: this is the status:

openhabian@openhabian:/etc $ sudo systemctl status zigbee2mqtt
● zigbee2mqtt.service - Zigbee2MQTT
   Loaded: loaded (/etc/systemd/system/zigbee2mqtt.service; enabled; vendor preset: enabled)
   Active: active (running) since Sat 2022-04-23 18:14:20 CEST; 23s ago
 Main PID: 28977 (npm)
    Tasks: 23 (limit: 4225)
   CGroup: /system.slice/zigbee2mqtt.service
           ├─28977 npm
           ├─28988 sh -c node index.js
           └─28989 node index.js

Apr 23 18:14:20 openhabian systemd[1]: Started Zigbee2MQTT.
Apr 23 18:14:21 openhabian npm[28977]: > zigbee2mqtt@1.25.0 start /opt/zigbee2mqtt
Apr 23 18:14:21 openhabian npm[28977]: > node index.js
Apr 23 18:14:24 openhabian npm[28977]: Zigbee2MQTT:info  2022-04-23 18:14:24: Logging to console and directory: '/var/log/zigbee2mqtt/2022-04-23.18-14-22al' filename: log.txt
Apr 23 18:14:24 openhabian npm[28977]: Zigbee2MQTT:info  2022-04-23 18:14:24: Starting Zigbee2MQTT version 1.25.0 (commit #6f1460e4)
Apr 23 18:14:24 openhabian npm[28977]: Zigbee2MQTT:info  2022-04-23 18:14:24: Starting zigbee-herdsman (0.14.20)

I think it has something to do with permissions (as suggested in the zigbee2mqtt documentation: this is the content of /var/log/zigbee2mqtt/.../log.txt

info  2022-04-23 18:14:24: Logging to console and directory: '/var/log/zigbee2mqtt/2022-04-23.18-14-22al' filename: log.txt
info  2022-04-23 18:14:24: Starting Zigbee2MQTT version 1.25.0 (commit #6f1460e4)
info  2022-04-23 18:14:24: Starting zigbee-herdsman (0.14.20)
error 2022-04-23 18:14:45: Error while starting zigbee-herdsman
error 2022-04-23 18:14:45: Failed to start zigbee
error 2022-04-23 18:14:45: Check https://www.zigbee2mqtt.io/guide/installation/20_zigbee2mqtt-fails-to-start.html for possible solutions
error 2022-04-23 18:14:45: Exiting...
error 2022-04-23 18:14:45: Error: Failed to connect to the adapter (Error: SRSP - SYS - ping after 6000ms)
    at ZStackAdapter.start (/opt/zigbee2mqtt/node_modules/zigbee-herdsman/src/adapter/z-stack/adapter/zStackAdapter.ts:102:27)
    at Controller.start (/opt/zigbee2mqtt/node_modules/zigbee-herdsman/src/controller/controller.ts:123:29)
    at Zigbee.start (/opt/zigbee2mqtt/lib/zigbee.ts:58:27)
    at Controller.start (/opt/zigbee2mqtt/lib/controller.ts:100:27)
    at start (/opt/zigbee2mqtt/index.js:101:5)

But when I try to fix the user-rights via Openhabian-config I get an invalid user error

$ fix_permissions /var/log/mosquitto mosquitto:openhabian 644 755
+ fix_permissions /var/log/mosquitto mosquitto:openhabian 644 755
+ [[ -e /var/log/mosquitto ]]
+ chown mosquitto:openhabian /var/log/mosquitto
+ [[ -n 644 ]]
+ [[ -f /var/log/mosquitto ]]
+ [[ -n 755 ]]
+ [[ -d /var/log/mosquitto ]]
+ find /var/log/mosquitto -type d -print0
+ xargs -0 chmod 755
+ return 0
+ return 0
+ zigbee2mqtt_is_installed
+ [[ -d /opt/zigbee2mqtt ]]
+ [[ -s /etc/systemd/system/zigbee2mqtt.service ]]
+ return 0
+ cond_redirect fix_permissions /var/log/zigbee2mqtt zigbee2mqtt:openhabian 644 755
+ [[ -n '' ]]
+ echo -e '\n\033[90;01m$ fix_permissions /var/log/zigbee2mqtt zigbee2mqtt:openhabian 644 755 \033[39;49;00m'

$ fix_permissions /var/log/zigbee2mqtt zigbee2mqtt:openhabian 644 755
+ fix_permissions /var/log/zigbee2mqtt zigbee2mqtt:openhabian 644 755
+ [[ -e /var/log/zigbee2mqtt ]]
+ chown zigbee2mqtt:openhabian /var/log/zigbee2mqtt
chown: invalid user: ‘zigbee2mqtt:openhabian’
+ return 1
+ return 1
+ echo 'FAILED (zigbee2mqtt log permissions)'
FAILED (zigbee2mqtt log permissions)
+ retval=1
+ zram_is_installed
+ [[ -s /etc/ztab ]]
+ return 1
+ echo OK

System information:

I'm using Openhabian MAIN on a RPi4

openhabian@openhabian:~ $ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
NAME="Debian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
openhabian@openhabian:~ $ uname -m
aarch64
mstormi commented 2 years ago

@Larsen-Locke could you please check

Larsen-Locke commented 2 years ago

could you please check the path of your zigbee-adapter? Try `ls -l /dev/serial/by-id' And then please check if the path of your adapter is correctly inserted in your configuration under /opt/zigbee2mqtt/data/configuration.yaml

MarijnO commented 2 years ago
openhabian@openhabian:~ $ ls -l /dev/serial/by-id
total 0
lrwxrwxrwx 1 root root 13 Apr 23 21:38 usb-FTDI_FT232R_USB_UART_AI1X0YQI-if00-port0 -> ../../ttyUSB0
lrwxrwxrwx 1 root root 13 Apr 24 09:01 usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_e239dc17b812ec11b40221c7bd930c07-if00-port0 -> ../../ttyUSB1

And here's a problem, the content of the configuration.yaml is not correct (wrong USB device, it's a serial-2-usb cable used to read-out my energy meter).

frontend:
  port: 8081
homeassistant: false
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://localhost
  user: xxxx
  password: xxxx
serial:
  port: /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_AI1X0YQI-if00-port0

Adjusting this via running the Openhabian-20-2A install or Update Zigbee2MQTT doesn't work

There was an error or interruption during the execution of:                  │
                    │   "20 | Optional Components"

Adjusting the file directly solved the problem for me!

I'm pretty sure I selected the correct USB device at the initial installation. Do you want me to check any other things? Or should I consider this as a user-error?

Larsen-Locke commented 2 years ago

I guess you selected the wrong one. Did you press space after selecting the right adapter? Otherwise it's not selected (can't change that. Whiptail works like that). If you could check that again that would be helpfull. This means uninstalling via the option in the menu and installing again.

MarijnO commented 2 years ago

OK, so this is what I did: step 1: manually change the USB adaper --> frontend is working step 2: via openhabian try to update zigmee2mqtt --> still the there was an error or interruption during the execution of: 20 | Optional Components message step 3: Use Openhabian to remove zigbee2mqtt step 4: Use Openhabian to install zigbee2mqtt again image Use arrow to go to the correct adapter. Then press space (I guess I pressed enter the first time) --> asterix now is in the correct position image

Now this throws an error at me

2022-04-24_20:36:35_CEST [openHABian] Updating Linux package information... OK
2022-04-24_20:36:37_CEST [openHABian] Removing Zigbee2MQTT service... OK
2022-04-24_20:36:37_CEST [openHABian] Uninstalling Zigbee2MQTT... OK
2022-04-24_20:37:52_CEST [openHABian] Updating Linux package information... 2022-04-24_20:37:52_CEST [openHABian] Updating Linux package information... OK

2022-04-24_20:40:07_CEST [openHABian] Downloading Zigbee2MQTT... Error: ENOENT: no such file or directory, uv_cwd
    at process.wrappedCwd (internal/bootstrap/switches/does_own_process_state.js:130:28)
    at process.cwd (/usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:10:19)
    at Conf.loadPrefix (/usr/lib/node_modules/npm/lib/config/load-prefix.js:46:24)
    at load_ (/usr/lib/node_modules/npm/lib/config/core.js:109:8)
    at Conf.<anonymous> (/usr/lib/node_modules/npm/lib/config/core.js:96:5)
    at Conf.emit (events.js:400:28)
    at ConfigChain._resolve (/usr/lib/node_modules/npm/node_modules/config-chain/index.js:281:34)
    at ConfigChain.add (/usr/lib/node_modules/npm/node_modules/config-chain/index.js:259:10)
    at Conf.add (/usr/lib/node_modules/npm/lib/config/core.js:338:27)
    at Conf.<anonymous> (/usr/lib/node_modules/npm/lib/config/core.js:314:25)
internal/bootstrap/switches/does_own_process_state.js:130
    cachedCwd = rawMethods.cwd();
                           ^

Error: ENOENT: no such file or directory, uv_cwd
    at process.wrappedCwd (internal/bootstrap/switches/does_own_process_state.js:130:28)
    at process.cwd (/usr/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:10:19)
    at process.errorHandler (/usr/lib/node_modules/npm/lib/utils/error-handler.js:183:30)
    at process.emit (events.js:400:28)
    at process._fatalException (internal/process/execution.js:167:25) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'uv_cwd'
}
FAILED (download)
2022-04-24_20:40:27_CEST [openHABian] Checking for default openHABian username:password combination... OK
2022-04-24_20:40:27_CEST [openHABian] We hope you got what you came for! See you again soon ;)
openhabian@openhabian:~ $

I'll try to reboot and let you know

Update: After reboot installation completed succesfully and frontend is starting.

So it must be that I've selected the correct zigbee adapter using the 'enter' key (and thus not selecting it).

Larsen-Locke commented 2 years ago

good to hear. So issue can be closed.

MarijnO commented 2 years ago

Yes, thx!