Hi Everyone!
I am moving my mqtt to 2.4 and i am struggling with an item that is controlling a tuya socket with the great tuya-mqtt script.
The old item is like this:
With the new binding i don’t have probelms to see the state with the thing/channel concept, but i can’t find in the binding documentation how to manage different topics ( command/on & command/off) and payloads (true/false) for the command to the ON/OFF status.
I am at this point and i don’t know how to continue. Of course commandTopic is wrong but i don’t know how to manage!
Thing mqtt:topic:tuyasocket1 (mqtt:broker:synBroker) {
Channels:
Type switch : tuya1 "Tuya Socket 1" [ stateTopic="tuya/socket/1582xxx/9179xxx/myip/state", commandTopic="tuya/socket/1582xxx/9179xxx/myip/command/", on="on", off="off" ]
}```
Somebody already solved this? Could you help me to find the proper documentation?
Thank you!
I’m on the phone so can’t get you the right link. Have a look for the openhab2-addons GitHub repository and find the mqtt.generic binding. The readme file in there is the newest not yet published documentation. It contains an example matching your case.
Oh right. This is indeed not covered by mqtt2. But for a reason. The Mqtt topic layout of that script is broken.
There are accepted conventions on how to use Mqtt and one is to have a single state expressed as one topic. The script should be adopted to how Mqtt is supposed to be used or indeed a rule is necessary in openhab.
Alternatively two channels with a different command topic each linked to the same item will do it maybe? (The second channels item link would be set with a follow profile).
If I recall, the tuya mqtt bridge code was changed and you should be able to use one topic only.
taken from:
Change device state (by payload)
Use with OpenHAB 2.X MQTT bindings or others where only a single command topic is preferred
tuya/<tuyaAPI-type>/<tuyaAPI-id>/<tuyaAPI-key>/<tuyaAPI-ip>/command // State as Payload (on,off)