You can archive this with MQTT1. MQTT2 does not support this broken MQTT topic design though. An MQTT topic represents one state and that’s what MQTT2 supports
I recommend some additional logic on your µController to software emulate a H-Bridge and have one MQTT topic only.
And in the case of a rollershutter, the received command is a number?
rule “Roller Shutter”
when
Item Shutter_GF_Living received command
then
if (receivedCommand == 100)
{
mqttActions.publishMQTT(“out/P_Prueba/state”,“ON”)
}
else (receivedCommand == 0)
{
mqttActions.publishMQTT(“out/P_Prueba/state”,“OFF”)
}
end
Not necessarily. As documented [here] (https://www.openhab.org/docs/concepts/items.html), Rollershutter can accept OnOff, IncreaseDecrease, and Percent as commands. But it stores is state only as a percent.
And how could I receive the same message from different topic? I mean, for example, I have 2 sensor, first “in/F_Garage_Door_Opened/state” send OPEN/CLOSE and second “in/F_Garage_Door_Closed/state” send OPEN/CLOSE too, but I’m only interested in the command OPEN from the two topic, and I would like to program a contact item that is OPEN when it is OPEN from “in/F_Garage_Door_Opened/state” and is CLOSE when it is OPEN from “in/F_Garage_Door_Closed/state”.
I tried this:
Mqtt thing:
Thing topic Garag_Contact “Garag_Contact” (mqtt:broker:mosquitto)
{
Channels:
Type contact : Garage_Contact_Opened “Garage Contact Opened” [stateTopic=“in/F_Garage_Door_Opened/state”]
Type contact : Garage_Contact_Closed “Garage Contact Closed” [stateTopic=“in/F_Garage_Door_Closed/state”]
}
There is a bug in the binding right now that makes this not possible using just one Item. You need two separate Items , one for each topic, and a Rule to forward the new states to Garage_Contact which will become a proxy Item not linked to any Channels.
There are cases, like for example with a Rollershutter, where it makes sense to split the topics: One topic for position commands and a seperated one for up and down commands as those are something completely different. As far as I can see this is not supported at the moment?