Current MQTT item state after reboot

Hi all

After searching without success I have a simple question
My item is simple switch bind to tasmota device and work as expected
The MQTT broker is mosquitto and installed on the same box with OH
After reboot or services restart the item is null or undef
I like to know the real state of the device (like zwave devices) and not what was the last state before restart
Is it possible?

Oded

If you are using openhab 2 then you can install a map persistence that will put the state back to what it was before you shut down.

If you need to ask tasmota you can do a startup rule in openhab to ask it what the state is.

Just send a empty message to the POWER command topic and it will report its state to you.

rule "Publish to get state when System started"
when
    System started 
then
   val mqttActions = getActions("mqtt","mqtt:broker:myMQTTBroker") //Change myMQTTBroker to you're broker name
   mqttActions.publishMQTT("cmnd/HAPPY_NEWYEAR/POWER", "value")
   mqttActions.publishMQTT("cmnd/Next/POWER", "value")
end

In addition to the options from next year’s @denominator, if you’re happy to wait up to 5 minutes for the actual state you can take advantage of Tasmota’s periodic reporting. See section 4 of the post below for an example:

1 Like

Thank you and happy_newyear :slight_smile: