Issue of the topic: I have a number of devices that run on Tasmota and communicate with OH via MQTT. The OH MQTT Binding always shows a thing status as ONLINE. Tasmota devices, on the other hand, utilize a special MQTT topic LWT (Last Will and Testament) that correctly reflects an Online/Offline status of a device.
Question: Is it possible and how to align/update an MQTT thing status with/from a specific MQTT topic? Can a thing status be updated from a Rule?
Please, note, that I am asking about a thing not an an item. Thanks in advance.
Thanks, but I don’t think it’s what I am looking for. The channels are dependants of a thing meaning that any particular channel does not have its own status. The thing status is common for all channels and has to be defined at the thing level.
Configuration of the MQTT Broker thing allows defining a Last will topic but which is kind of I am looking for on the thing level. From the documentation it’s not clear what this topic is used for and whether it’s applicable for discovering things’ statuses, and also if it can be configured with wildcard syntax for different things.
Can anyone shed more light on this?
On every Generic MQTT Thing you can set a LWT topic and an online and offline message in it’s configuration. When the LWT has the offline message posted the Generic Thing will be marked as OFFLINE and all the Items linked to the Channels will be set to UNDEF.
Note that for this to work the device needs to publish both an ONLINE and OFFLINE message to the LWT topic and the messages must be published as retained.
label: Cerberos sensor_reporter
- id: garagedoor1
label: Large garage door
description: Large garage door open status
- id: garagedoor2
label: Small garage door
description: Small garage door open status
- id: garagedoor1_opener
label: Large garage door opener
- id: garagedoor2_opener
label: Small garage door opener
description: Small garage door opener controller
- id: online
label: Online status
description: Indicates online status of this sensor_reporter
I missed that. If that’s the case @aturlov, the answer is no, you can’t. The 2.4 version binding doesn’t have these options to set the LWT on the Generic MQTT Thing and there is no way to set the status of a Thing from a Rule.
Thing status can updated from REST API in a way - you can enable or disable it at least. Disabled will result in status OFFLINE, enabling will do whatever initializing is needed and go eventually to ONLINE all being well.
I do not think you can manipulate Thing status directly, because that is the binding’s job.
You can use REST API from a rule with sendHttpGetRequest() or similar.
I’m not convinced you need to do this though …
There’s no problem with that. The Thing does not represent the device really, it represents a collection of topics you might be listening to from a broker. You’ve no idea when the next message might come, even if you think the device is currently powered off. If you disable/OFFLINE this Thing you will never find out when it wakes up.
The Thing status really represents your listening ability to the broker.