Hello community,
I am on the move from MQTT 1.x and Mosquitto to the new 2.4 Binding. I am using MQTT together with the Tuya/MQTT-Binding of @AgentK. So I thougt to start small and make only one tuya bulb working.
I followed the instructions given here:
The “old” MQTT-1.x-item which worked was:
Switch tuya_OG_Schlafzimmer1 <light> (group_OG_Schlafzimmer_Licht) {mqtt="<[broker:tuya/lightbulb/12204702807d3a49b2ae/dd28170cbf5dcd08/192.168.75.118/state:state:default:.*], >[broker:tuya/lightbulb/12204702807d3a49b2ae/dd28170cbf5dcd08/192.168.75.118/command/on:command:ON:true], >[broker:tuya/lightbulb/12204702807d3a49b2ae/dd28170cbf5dcd08/192.168.75.118/command/off:command:OFF:false]"}
So I defined my bridge and generic thing accordingly:
mqtt.things
Bridge mqtt:broker:myUnsecureBroker [ host="127.0.0.1", secure=false ]
{
Thing mqtt:topic:mything {
Channels:
Type switch : Tuya_Bulb_1_mqtt "LED1 MQTT" [ stateTopic="tuya/lightbulb/12204702807d3a49b2ae/dd28170cbf5dcd08/192.168.75.118/state", commandTopic="tuya/lightbulb/12204702807d3a49b2ae/dd28170cbf5dcd08/192.168.75.118/command" ]
}
}
The thing in Paper UI:
I copied the channel from PaperUI:
And set up an item and linked to the channel:
Switch tuya_OG_Schlafzimmer1_mqtt <light> {channel="mqtt:topic:mything:Tuya_Bulb_1_mqtt"}
And integrated in sitemap:
Switch item=tuya_OG_Schlafzimmer1_mqtt mappings=[ON="On", OFF="Off"]
When I use “Smart Life” (the app for controlling the Tuya bulb) to switch the bulb, OH correctly reflects the status of the bulb. So in principle things work.
2019-01-10 21:21:48.651 [vent.ItemStateChangedEvent] - tuya_OG_Schlafzimmer1_mqtt changed from ON to OFF
2019-01-10 21:22:10.846 [vent.ItemStateChangedEvent] - tuya_OG_Schlafzimmer1_mqtt changed from OFF to ON
But switching in OH does not affect the bulb, it stays in the same state as I set it in the Smart Life app. Even log says:
2019-01-10 21:23:27.711 [ome.event.ItemCommandEvent] - Item 'tuya_OG_Schlafzimmer1_mqtt' received command OFF
2019-01-10 21:23:27.717 [nt.ItemStatePredictedEvent] - tuya_OG_Schlafzimmer1_mqtt predicted to become OFF
2019-01-10 21:23:27.720 [vent.ItemStateChangedEvent] - tuya_OG_Schlafzimmer1_mqtt changed from ON to OFF
What point am I missing? I defined stateTopic and actionTopic in the generic MQTT-thing, but only stateTopic is working.
And bonus question: How can I get rid of the mapping in the sitemap, I want a “regular” switch?