Hello,
I have question regarding how to deal with MQTT topics.
I have the following flow that I use to control a sensirion MFC5500. The flow works well without bug. The one problem that I have is when I want to do read the sensor value, I inadvertently created an endless loop.
I trigger a measurement by sending a payload ( "-") on the topic mfc/A01/read. The sensor returns its value as a new payload on the same topic; which starts an infinite loop. In itself it is not the worst unforeseen issue since I need to get measurement at regular intervals, but I would rather have a little bit more control as to when those happen.
What would be the best practice to deal with a situation like this? Is it to check the type of payload (ex. string vs. number) and ignore messages that are not the right type? Is it to create a different topic for the sensor data in a separate branch?
In this specific instance I have multiple type of sensors and it is convenient for me to segregate them by type (ex. mfc, temp, pressure, etc..) and then using a different topic to identify the specific sensor (ex. A01, H03, etc...).
I know their might not be one right solution, I am just curious what the hive mind thinks.
Thank you in advance.
W.