I’m using ESP8266 with Arduino code. Each device posts a ‘state’ and an ‘avail’ messages for a specific topic.
I wish to be able to read those retained messages and not only right after connecting and subscribe to MQTT broker.
EDIT 1 - Clarifications
- I'm using Raspberry Pi Zero W as a MQTT Broker ( Local ).
- When device boots, it changes its state from
online, but a different process checks periodically if state is
onlinefor current device and others on the network.
- it is not same as when subscribing to a retained topic, that you get the state at that specific time.
- Storing chage of state in a variable, is one way to do it, but is there a different way ?