Unable to Use MQTT State Topic

Hi All Experts,
I am using OpenHab 3 on RPi 4.
I also have MQTT Broker running on this server that is used to communicate between my Server and NodeMCU clients.

Each of my client subscribe to a topic on the RPi MQTT Server and perform the action accordingly such as On/Off switch, curtain open or close, etc.

Everything is working fine except that I am not able to get the current state of the NodeMCU switches. I tried setting up the MQTT State Topic on the configuration screen but that doesn’t seems to be working.

I specified a State Topic and handled that in each of my Node MCU Client in such a way that if any message is published to that topic, the NodeMCU will publish the current state of the Pin.
However, this strategy doesn’t seems to be working.

Can someone please help me understand what wrong I am doing? Below is my Sample Configuration Screen:

Do mean something has to poll your devices, sending them some message before they respond with their own message?

openHAB does not do any active polling on MQTT, it is assumed that remote devices publish messages by themselves. It’s just not the way MQTT architecture is normally used.
stateTopic therefore just listens.

You’ll have to set up commandTopics and probably cron rules and so on if you needto create a poller mechanism.

Thank you for your reply.

I was under impression that OpenHab will poll to the State Topic.
I will try to create the polling mechanism from my NodeMCU device and let you know if that works.

Thank you once again for your quick reply :slight_smile:

As rossko mentioned, you can setup a cron job or similar to pull, but it does not do it automatically as most MQTT procedures actually publish from their end, that’s also easier to implement in OH then.

In general, MQTT devices publish when they have something to say i.e. a change to report. Perhaps in conjunction with a periodic summary.

OH channel stateTopic = passively subscribed to
commandTopic = actively publish to, but on demand only (by command to linked Item).

This solution works as expected.
Thank you once again!