Thanks rossko,
I’ll read up on mapdb and try it out.
This is going off-topic, but quickly: here’s how I regain my MQTT switch states after OpenHAB startup:
Note: My switches have Tasmota loaded, I’m using a stand-alone Mosquitto MQTT broker, and I have a bridge defined in a separate things file.
Thing
Subscribe to the Tasmota *STATE* topic using a switch called *State*. Tasmota automatically sends out this *STATE* message periodically (for me it seems to be every few minutes). // Switch Living Room Tall Light
Thing mqtt:topic:swLivingRoomTallLight "Switch Living Room Tall Light" (mqtt:broker:MosquittoMqttBroker) {
Channels:
Type switch : switch "Power Switch" [
stateTopic="stat/swLivingRoomTallLight/POWER",
commandTopic="cmnd/swLivingRoomTallLight/POWER",
on="ON",
off="OFF"
]
Type switch:state "State" [
stateTopic="tele/swLivingRoomTallLight/STATE",
transformationPattern="JSONPATH:$.POWER",
on="ON",
off="OFF"
]
}
Item
Add the *State* channel to your existing switch item. An item can have multiple channels, separated by a comma.Switch sLivingRoomTallLight "Living Room Tall Light" { channel="mqtt:topic:swLivingRoomTallLight:switch", channel="mqtt:topic:swLivingRoomTallLight:state" }
That’s it. After an OpenHAB restart all your switches will automatically update over the course of a few minutes, depending upon when Tasmota sent out the last STATE message.
1 Like
rossko,
MapDB Binding working fine.
Thank you once more.