Zigbee2Mqtt entity states in Home Assistant don't represent actual state

I’m transitioning from the Hue Bridge to vanilla Zigbee, but the auto-discovered entities in HA don’t represent the reality of the lights.

For example, if I turn on a light in the Zigbee2MQTT front end, the entity in Home Assistant doesn’t update.

Likewise, if I manually turn ON the front-end switch in HA, the physical light will turn on, but the front-end switch will revert to the OFF position.

Here’s my Zigbee2Mqtt config (generated by the UI):

homeassistant:
  legacy_triggers: true
  legacy_entity_attributes: false
permit_join: true
mqtt:
  base_topic: zigbee2mqtt
  server: mqtt://192.168.1.204
serial:
  port: /dev/sonoff_zigbee
  adapter: ember
  baudrate: 115200
frontend:
  port: 8080
advanced:
  network_key:
    - 59
    - 218
    - 190
    - 242
    - 100
    - 209
    - 52
    - 251
    - 251
    - 54
    - 27
    - 201
    - 249
    - 119
    - 215
    - 180
  homeassistant_legacy_entity_attributes: false
  legacy_api: false
  legacy_availability_payload: false
device_options:
  legacy: false
devices:
  '0x0017880106d8e2a2':
    friendly_name: Hue White 1
    homeassistant: {}
    optimistic: true
  '0x0017880106d8fc12':
    friendly_name: Hue White 2
    homeassistant: {}
    optimistic: true
  '0x001788010273b7a4':
    friendly_name: Parlour Window
  '0x001788010271a496':
    friendly_name: Parlour Sofa
groups:
  '1':
    friendly_name: WhiteLightsTest
    devices:
      - 0x0017880106d8e2a2/11
      - 0x0017880106d8fc12/11
  '2':
    friendly_name: Parlour Lights
    devices:
      - 0x001788010271a496/11
      - 0x001788010273b7a4/11

If I turn on, say, Hue White 1 from the Zigbee2Mqtt interface, it broadcasts the MQTT message properly:

zigbee2mqtt/Hue White 1
{"brightness":165,"linkquality":120,"power_on_behavior":"previous","state":"ON","update":{"installed_version":16787458,"latest_version":16787458,"state":"idle"},"update_available":null}

The discovery topic is obviously working because the entity shows up in Home Assistant (light.hue_white_1).

  • Zigbee2MQTT version 1.40.0 commit: 6fa1dab
  • Home Assistant Core 2024.8.2

Any idea what I’m doing wrong here?

Sigh. I had to force refresh the browser? A freaking widget doesn’t work properly because my freaking browser needs to be freaking refreshed? When’s the next WTF event so that I can complain about this?? :wink:

In any case, I tried access from a browsers on another machine, and simply thought that time allowed MQTT to catch up or flush out or whatever, but nope, back to the original browser the behavior above exhibited itself once again. Force-refresh fixed it.

Wild guess, but make sure your Automatically close connection setting is not enabled:

To find it, click your profile picture in the bottom left, then scroll down to the browser settings section

Hello,

I have the exact same problem.

I have a fresh HAOS install with zigbee2mqtt. After running the system for a few hours, some entities started acting like described in the first post.
It doesn’t depend on the browser since I have the same behavior on my pc, the compagnon app on Android and IOS. Although every entities show up as they should in zigbee2mqtt.
There is a mismatch between the zigbee2mqtt and HA entity state.

I really have no idea what to do first.
I tried restarting everything, re-adding the devices and it had no effect whatsoever.

Edit : It ended up fixing itself. No problem for the past few days.