# MQTT device status check

**URL:** <https://community.homey.app/t/mqtt-device-status-check/48740>\
**Category:** 🇳🇱 Nederlands (Dutch)\
**Tags:** mqtt\
**Created:** [June 23, 2021, 10:10pm UTC](https://community.homey.app/t/mqtt-device-status-check/48740 "2021-06-23T22:10:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dirk\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirk_d/32/34994_2.png) [@Dirk\_D](https://community.homey.app/u/Dirk_D)\
**Post date:** [June 23, 2021, 10:10pm UTC](https://community.homey.app/t/mqtt-device-status-check/48740/1 "2021-06-23T22:10:49Z")

</div>

Hi,

I’m using MQTT Hub on my Homey to control lights and other devices via an Android application i build using ‘Kodular’.

This is pretty much working allready. I can turn lights on and off with the app, but when the app starts up i want the app to check all the the device status so the device status in the app match the device status in real life from the beginning.

It must be possible because i used Home Assistant for a dashboard via MQTT and the status there was always up to date.

Anybody?

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [June 24, 2021, 7:33pm UTC](https://community.homey.app/t/mqtt-device-status-check/48740/2 "2021-06-24T19:33:53Z")

</div>

All device state messages are retained on the broker. So all messages should come in immediately when you subscribe to the device topics.

---

<div class="post-metadata">

**Author:** ![Dirk\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirk_d/32/34994_2.png) [@Dirk\_D](https://community.homey.app/u/Dirk_D)\
**Post date:** [June 24, 2021, 8:40pm UTC](https://community.homey.app/t/mqtt-device-status-check/48740/3 "2021-06-24T20:40:34Z")

</div>

Hi Harrie,  
Thanx for your replay.  
That’s what i thought. But no message comes in after i subscribe. Only after a status is altered a message comes in.  
Could it be that I need to change settings in the MQTT hub, broker or client?

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [June 25, 2021, 6:41am UTC](https://community.homey.app/t/mqtt-device-status-check/48740/4 "2021-06-25T06:41:28Z")

</div>

Does each device state appear as a unique topic?  
I have one hub that sends each device update to the same topic, therefore overwriting the previous state for a device.  
Also I’m not sure if the Qos level will affect it.  
If you use an MQTT monitor, like MQTT Explorer, can you see the state of each device?

---

<div class="post-metadata">

**Author:** ![Dirk\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirk_d/32/34994_2.png) [@Dirk\_D](https://community.homey.app/u/Dirk_D)\
**Post date:** [June 25, 2021, 8:35am UTC](https://community.homey.app/t/mqtt-device-status-check/48740/5 "2021-06-25T08:35:23Z")

</div>

Hi Adrian,  
Each device has its own topic. Even multiple topics like: ‘/onoff’,’/dim’ and ‘/powerusage’  
In MQTT Explorer everything is visible and clear. And only after altering one of the variables an update is send. Maybe there is a topic like /get or a payload like ? that responds with the current state without changing it.

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [June 25, 2021, 9:38am UTC](https://community.homey.app/t/mqtt-device-status-check/48740/6 "2021-06-25T09:38:44Z")

</div>

Hmm, strange, so as Harrie says, as soon as you subscribe you should get any updates that have been missed.  
I’m not sure if you would get any messages that you have already received before you disconnected if you connect using the same client ID.

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [June 25, 2021, 9:42am UTC](https://community.homey.app/t/mqtt-device-status-check/48740/7 "2021-06-25T09:42:17Z")

</div>

Do you use an external broker or the Homey broker app?

---

<div class="post-metadata">

**Author:** ![Dirk\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirk_d/32/34994_2.png) [@Dirk\_D](https://community.homey.app/u/Dirk_D)\
**Post date:** [June 29, 2021, 7:56pm UTC](https://community.homey.app/t/mqtt-device-status-check/48740/8 "2021-06-29T19:56:39Z")

</div>

> [@Adrian\_Rockall](#):
>
> I’m not sure if you would get any messages that you have already received before you disconnected if you connect using the same client ID.

I have tried disconnecting and reconnecting and unsubscribe and subscribing again. But still no messages.

> [@HarriedeGroot](#):
>
> Do you use an external broker or the Homey broker app?

I’m using [this MQTT Broker](https://homey.app/nl-nl/app/nl.scanno.mqttbroker/MQTT-Broker/) by Menno van Grinsven in combination with [MQTT Client](https://homey.app/nl-nl/app/nl.scanno.mqtt/MQTT-Client/) and MQTT Hub  
I don’t know if that is ‘the Homey broker app’.

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [June 29, 2021, 8:10pm UTC](https://community.homey.app/t/mqtt-device-status-check/48740/9 "2021-06-29T20:10:32Z")

</div>

@Dirk_D The Homey broker has [known limitations](https://community.homey.app/t/mqtt-hub-gateway/6766/970) in handling retained messages. I would recommend running an external broker (e.g. [mosquitto](https://mosquitto.org/)).

An alternative approach can be to send a ‘birth message’. This will trigger a broadcast of the Hub. Not the ideal solution, but at least you’ll get the latest values.

---

<div class="post-metadata">

**Author:** ![Dirk\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirk_d/32/34994_2.png) [@Dirk\_D](https://community.homey.app/u/Dirk_D)\
**Post date:** [July 1, 2021, 7:06pm UTC](https://community.homey.app/t/mqtt-device-status-check/48740/10 "2021-07-01T19:06:53Z")

</div>

Is it possible to install mosquito on Homey or should it be on a separate device?

---

<div class="post-metadata">

**Author:** ![HarriedeGroot](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/harriedegroot/32/56160_2.png) [@HarriedeGroot](https://community.homey.app/u/HarriedeGroot)\
**Post date:** [July 2, 2021, 6:56am UTC](https://community.homey.app/t/mqtt-device-status-check/48740/11 "2021-07-02T06:56:39Z")

</div>

Separate device, e.g. Synology NAS or raspberry pi.

---

<div class="post-metadata">

**Author:** ![Dirk\_D](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirk_d/32/34994_2.png) [@Dirk\_D](https://community.homey.app/u/Dirk_D)\
**Post date:** [August 5, 2021, 8:00pm UTC](https://community.homey.app/t/mqtt-device-status-check/48740/12 "2021-08-05T20:00:39Z")

</div>

I’ve put mosquito on a rpi and it works perfect.  
So it’s the Homey Broker that doesn’t work.  
Thanx…
