Zigbee2MQTT: Devices become unavailable after saving config trough frontend

Hi,

I have the following problem. Zigbee2MQTT runs fine as far as I don’t save the configuration trough the front end. After saving and after a restart the devices become unavailable after a bit trying out and using MQTT Explorer I found out that the reason for that seams to be that device are now reported directly under the “homeassistant” topic instead as a sensor or as a switch

Here is my configuration that works (at the moment)

homeassistant:
  discovery_topic: homeassistant
  status_topic: homeassistant/status
  legacy_entity_attributes: true
  legacy_triggers: true
zigbee_herdsman_debug: true
permit_join: true
mqtt:
  server: mqtt://core-mosquitto:1883
  user: '!secret zigbee2mqtt_user'
  password: '!secret zigbee2mqtt_password'
  keepalive: 60
  reject_unauthorized: true
  version: 4
  client_id: zigbee2mqtt

  include_device_information: true
serial:
  port: >-
    /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_2eaa1d155b9cec118a14634d73138bba-if00-port0
frontend:
  port: 8099
devices:
  '0x00158d0003569a2b':
    friendly_name: Innr Smart Plug
    homeassistant:
      name: Innr Smart Plug
    optimistic: true
  '0x0015bc001b021d85':
    friendly_name: Hauptstromzähler
    homeassistant:
      name: Hauptstromzähler
    optimistic: true
  '0x00158d0003623499':
    friendly_name: Innr Smart Plug 2
    homeassistant:
      name: Innr Smart Plug 2
    optimistic: true
availability: true

If I save the config through the front end I get a line added under mqtt:

base_topic: zigbee2mqtt

or

base_topic: homeassistant

after an reboot the problems starts and only deleting that line and restarting solves it.
The front end says that this base_topic must not be null so I can’t delete the value in the fron end.

To what value do I have to set base_topic that the devices appear under sensor and switch where they belong to?

Thank you!

BTW. Is there a way to set the front end to dark theme as I have the whole homeassistant front end?

Where are you saving this configuration?

This is my working config/zigbee2mqtt/configuration.yaml file contents:

external_converters:
  - ext_converter.js
devices:
  - devices.yaml
groups:
  - groups.yaml
homeassistant: true
permit_join: false
mqtt:
  base_topic: zigbee2mqtt
  user: #<redacted>#
  password: #<redacted>#
  server: mqtt://core-mosquitto:1883
serial:
  port: tcp://10.1.1.210:6638
advanced:
  log_level: warn
  pan_id: 6754
  channel: 11
  network_key: #<redacted>#
  availability_blocklist: []
  availability_passlist: []
device_options: {}
blocklist:
  - '0x00124b000639b8f6'
passlist: []
queue: {}
frontend:
  port: 8099
experimental: {}
availability: false

And AGAIN all device are not available anymore!

Fantastic! Now I have “502 Bad Gateway”

Little hint: If you use “!secret” in your configuration the addon seams to expect a secret.yaml under /confg/zigbee2mqtt

Ok,

got it running again…for now

homeassistant:
  discovery_topic: homeassistant
  status_topic: homeassistant/status
  legacy_entity_attributes: true
  legacy_triggers: true
zigbee_herdsman_debug: true
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://core-mosquitto:1883
  user: "!secret zigbee2mqtt_user"
  password: "!secret zigbee2mqtt_password"
serial:
  port: >-
    /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_2eaa1d155b9cec118a14634d73138bba-if00-port0
frontend:
  port: 8099
advanced:
  # Optional: Add a last_seen attribute to MQTT messages, contains date/time of last Zigbee message
  # possible values are: disable (default), ISO_8601, ISO_8601_local, epoch (default: disable)
  last_seen: 'ISO_8601_local'
devices:
  "0x00158d0003569a2b":
    friendly_name: Innr Smart Plug
    homeassistant:
      name: Innr Smart Plug
    optimistic: true
  "0x0015bc001b021d85":
    friendly_name: Hauptstromzähler
    homeassistant:
      name: Hauptstromzähler
    optimistic: true
  "0x00158d0003623499":
    friendly_name: Innr Smart Plug 2
    homeassistant:
      name: Innr Smart Plug 2
    optimistic: true

This one works for now.

And AGAIN devices are not available! That sucks!

Now they are available again… don’t what causes this behavior !

Neither do we without your logs. Zigbee2Mqtt, system, and supervisor logs.

Also, looking at how different the yaml format they are, I suspect the format and structure OP is using is not correct to begin with, or at least not 100% correct any more.

IIRC, z2m started the shift from yaml to frontend UI to manage configuration… since 1.25 I believe. Please check change logs and docs of z2m from its Github page, and I believe there was a breaking change per z2m Github because of this.
… which might explain why you could roll your configs in yaml manually (in a different format), but then as soon as you touch the z2m frontend UI, things start to go south.

FWIW, the format/structure of my config/zigbee2mqtt/configuration.yaml is a lot closer to Tom’s in post #2, than yours in #1 or #6.
I also have base_topic: zigbee2mqtt in mine.
I also do not have devices: section in the same yaml.

So even if yours is working now, there might still be other issues you would want to address.
My 2 cents.

2 Likes