Not act on MQTT topic/payload from own client

I have had to create a status group of topics and a control group of identical topics for MQTT device management. This is due to the local code controlling the device, and then sending an update to the topic that the status was changed.

For example: Lights are 0 for off and 1 for on. If the arduino receives a 0 or 1, it sets the lights accordingly and then publishes the new status (0 or 1). Since it is subscribed to the topic, it sees its own published content, then updates the device again, and publishes...repeat.

It was easy to create a "control" topic that avoids this (Home/Lights and Home/Control/Lights for example), but that makes node red more complex than needed to create a web UI.

Is there a way to have the pubsubclient not process MQTT publications from the local client? The callback function appears to only give me topic and payload.

Add extra data to the payload indicating whether it is a status or command message.

mikb55:
Add extra data to the payload indicating whether it is a status or command message.

Indeed. I have thought of adding and "action" bit to the payload and am also thinking just adding new payloads for reporting only. 0 and 1 could be off/on action payloads and 2 and 3 could be matching status payloads.