Is it better to publish and subscribe in the same MQTT topic or have seperate topics?

Hello,
I use an esp8266 to communicate through MQTT with openhab and i have a question about mqtt topics.
Which is preffered: publish and subscribe in the same topic or have separate topics - one for commands and one for the state?

Tasos

Ooh, good question - subscribing :slight_smile:

When I’ve done it I’ve used separate topics, probably because that’s what I’d read. Given I have other Wemos to deploy I’m trying to write the code and mqtt so I can deploy the same code to multiple devices. I have in/out topics on a main channel just for each device being told it’s what its own topics are, then each device also has its own in/out topics. I wrote the arduino code as generic as possible so can get/see digital and analog pins, read voltage, read rssi etc. However means the smarts at the other end of the broker (openhab) need to know what each device does

1 Like