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.
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?
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?
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.
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.
@Dirk_D The Homey broker has known limitations in handling retained messages. I would recommend running an external broker (e.g. mosquitto).
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.