Is there a way to get a channel's last update data by using MQTT API?
2 views (last 30 days)
When a client sensor device power on, it needs to follow all the parameters that the system sets.
I use one channel to collect sensor data and use another one to pass parameters to the sensor.
Using HTTP API, it is easy to get all channel data at once, such as URL:
When devices are limited by the computer power, they only use MQTT API, It seems no way to get the latest data in a channel after just powering on.
Even sensor uses subscribe function, it must wait until the next update and then gets all the correct parameters.
Is there a way could get a channel's last update data by using MQTT API as the client's request?
Christopher Stapels on 1 Jul 2022
There is not a way to get the last update via MQTT. Here is a fairly complicated workaround however:
Set up a react on a new channel (say channel B) that triggers code to repeat the last value writted to channel A. Then set that react to trigger on insert to the channel. Now the device is subscribed to channel A, and does MQTT publish to channel B. The react triggers, and writes to channel A, and the devices gets the updated value via its subscription.