Zigbee2mqtt or OH doesn't update status of the attribute

Hi,
I have a zigbee door sensor which sends updates of its status every 3 hours (or immediately it the status is changed). I’ve connected OH with Z2M and I see the status change, but OH doesn’t record status update when the status is not changed. It seems the issue is between OH and Z2M, but I don’t know where and how to fix it.

If I use OH Zigbee binding then everything works correctly.

If you are looking in the event log, updates (with no change) are suppressed. From log4j2.xml

|||<Logger level=ERROR name=openhab.event.ItemStateEvent/>|
|---|---|---|
|||<Logger level=ERROR name=openhab.event.ItemStateUpdatedEvent/>|

But maybe I misunderstood your question…

PS: if this was your question, you can see these messages in the developer sidebar

If nothing’s wrong with your installation then zigbee2mqtt should transfer all item updates to openhab.
Usually you don’t use updates within rules so much but I just tried and it works. Just create a rule that is triggered by an update event and let the rule write something to the log

What are you seeing from the Zigbee binding (e.g. log entries, rule triggers) that you’re not seeing from Z2M?

If you don’t have the transform you won’t see any changes in OH.
Example below:

UID: mqtt:topic:mqttbroker:0bc8c6461a
label: Zigbee door back sensor
thingTypeUID: mqtt:topic
configuration:
  payloadNotAvailable: offline
  payloadAvailable: online
  transformationPattern: JSONPATH:$.state
  availabilityTopic: zigbee2mqtt/door-back/availability
bridgeUID: mqtt:broker:mqttbroker
location: Kitchen small deck
channels:
  - id: zigbeedoorback
    channelTypeUID: mqtt:contact
    label: Zigbee door back
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/door-back
      transformationPattern: JSONPATH:$.contact
      off: "true"
      on: "false"
  - id: zigbeedoorbackbattery
    channelTypeUID: mqtt:number
    label: Zigbee door back battery
    description: ""
    configuration:
      stateTopic: zigbee2mqtt/door-back
      transformationPattern: JSONPATH:$.battery
      unit: "%"

Thx for all answers!
Let me clarify the situation. I have door sensor linked with switch Item and datetime item (update type) linked to switch item. Thanks this, when I have Zigbee binding I see when the switch item was updated (about every 3h, even without state change). But… when I use Zigbee2MQTT, the item is updated only when the door is opining or closing. As Larsen mentioned, it will not be big deal unless unexpected power outage In this case, after OH startup, my switch item has NULL state until someone opens/closes the door. With Zigbee binding I just have to wait up to 3h .

If that is the case then you need to add the item to persistence so when OH starts it will be restored.
Use mapdb persistence.

Yes, but on this case I will not be sure if the restored value from mapdb match the real door’s state (maybe someone had open the door during the power outage)

If there is a power outage the zigbee2mqtt server would be down or the wifi would be down?

If they have UPS then you should set retention on the mqtt topic. That way when openhab comes back up then it would get the retained value.

Z2M and OH servers are on the same RPI machine, so both will be down, except the battery door sensor :wink:

you can do this a little easier: Every device in zigbee2mqtt has a last_seen attribute by default.

My thing definition looks like this:
UID: mqtt:topic:Contactn1
label: Contactn1
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:MosquittoMqttBroker
channels:
  - id: contact
    channelTypeUID: mqtt:switch
    label: contact
    configuration:
      retained: false
      postCommand: false
      formatBeforePublish: "%s"
      stateTopic: zigbee2mqtt/Contactn1/contact
      off: "false"
      on: "true"
  - id: battery
    channelTypeUID: mqtt:number
    label: battery
    configuration:
      retained: false
      postCommand: false
      step: 1
      formatBeforePublish: "%s"
      stateTopic: zigbee2mqtt/Contactn1/battery
  - id: last_seen
    channelTypeUID: mqtt:datetime
    label: last_seen
    configuration:
      retained: false
      postCommand: false
      formatBeforePublish: "%s"
      stateTopic: zigbee2mqtt/Contactn1/last_seen

Then I check in a rule if the time difference between now and a member of my last_seen-group is higher than 6 hours and in that case send a message via telegram.