Zigbee2mqtt last_seen


I’m missing something and I can’t see what. Let’s me explain:

I’ve zigbee2mqtt working, and I added

  last_seen: ISO_8601_local

In the zigbee2mqtt it’s ok:

info  2021-06-07 09:52:29: MQTT publish: topic 'zigbee2mqtt/0x04cf8cdf3c7e4ffd/temperature', payload '34'
info  2021-06-07 09:52:29: MQTT publish: topic 'zigbee2mqtt/0x04cf8cdf3c7e4ffd/voltage', payload '241'
info  2021-06-07 09:47:36: MQTT publish: topic 
'zigbee2mqtt/0x04cf8cdf3c7e4ffd/last_seen', payload '2021-06-07T09:47:36+01:00'

But in openhab, this specific channel doesn’t work:

                Type number             : temperature                   "Temperature"                                   [ stateTopic="zigbee2mqtt/0x04cf8cdf3c7e4ffd/temperature" ]
                Type number             : voltage                       "Voltage"                                       [ stateTopic="zigbee2mqtt/0x04cf8cdf3c7e4ffd/voltage" ]
                Type datetime   : last_seen                             "Last Seen"                                     [ stateTopic="zigbee2mqtt/0x04cf8cdf3c7e4ffd/last_seen" ]

In items i’ve have:

Number                  GP1_SmartPlug_voltage                    "Tomada  Voltage"                            <energy>                                          { channel="mqtt:topic:rabbitmq:mi-smart_plug:voltage" }
Number                  GP1_SmartPlug_linkquality                "Tomada  Link Quality"                       <qualityofservice>                { channel="mqtt:topic:rabbitmq:mi-smart_plug:linkquality" }
DateTime                GP1_SmartPlug_last_seen                  "Last Seen [%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS]"   <calendar>                                 { channel="mqtt:topic:rabiitmq:mi-smart_plug:last_seen" }

But as I say, the last_seen item doesn’t have a value:

2021-06-07 09:51:25.006 [INFO ] [penhab.core.model.script.teste.rules] - Last Seen: GP1_SmartPlug_last_seen (Type=DateTimeItem, State=NULL, Label=Last Seen, Category=calendar....

Can anyone see the problem?

Best Regards,

1 Like

The last_seen is a good idea.
I just added it and it works.
I don’t use the files way of doing it so can’t suggest anything for you. I did it all via the UI in OH3.
Thanks for the idea.

Based on your files config, and comparing it to my UI config I cannot see much wrong with it:



Seems that there is something missing between z2mqtt and OH though as the message is sent in z2mqtt.

edit: Also, you might want to change to friendly names for your z2mqtt config as it will be much easier to identify the item and use it in OH.

edit2: Maybe one test you can do is to take out the “[%1$tY-%1$tm-%1$td %1$tH:%1$tM:%1$tS]” of the item and see if the raw data is coming in; my stateDescription is “%1$tA, %1$tB %1$td, %1$tY - %1$tl:%1$tM %1$tp”

Looks like you have a typo here in your Item definition, based on the other two Items.

Lol, you’re right :slight_smile: I don’t see that :slight_smile:

Thanks a lot,