Hello, I asked this before in a German openHAB forum, because I am not a native English speaker and some of the technical details I found in this official forum are not easy to understand in the complete depth. I got there some nice support, but actual not a solution so I hope that perhaps someone here can support to find the reason for my problem.
I had a working openHAB 2.5.4 installation where the most items are connect with the KNX binding. Now I want to export the item status over MQTT and also be able to control with MQTT, too.
So i installed additional the MQTT binding 2.5.4 and installed the Mosquitto broker inside the linux machine, where also my openHAB installation runs. I used Mosquitto, because I found some threads with the information, that the openHAB MQTT Broker will get no future development.
My mqtt.things file:
Bridge mqtt:broker:mosquitto "Mosquitto MQTT Broker" @ "openHAB" [
host="localhost",
port=1883,
secure=false,
clientID="openHAB"
] {
Thing topic mqtt_bj_reg_1_1_2_dg "(MQTT KNX 1.1.2)" @ "Treppenhaus Büro" {
Channels:
Type switch : mqtt_d1_a2_k1 "Deckenlampen 1 Büro" [ stateTopic="openHAB/KNX/1/4/16/state", commandTopic="openHAB/KNX/1/4/16/command", on="1", off="0", postCommand=true, retained=true ]
}
}
First I had no mapping in the Channel switch and openHAB wrote to the topic “0” and “1”. So I tried to map this. I found this information inside some other threads. The item looks this this inside my knx.items file:
Switch s_dg_buero_deckenleuchten_1 "Deckenleuchten 1 Büro" <light> (gBuero_N, gLicht, gSchalter) { channel="knx:device:bridge:bj_reg_1_1_2_dg:d1_a2_k1", channel="mqtt:topic:mosquitto:mqtt_bj_reg_1_1_2_dg:mqtt_d1_a2_k1", alexa="Switchable" [category="LIGHT"] }
Now what I actual have is:
- I can switch the lights with the physical switches and the virtual switches of the Basic UI
- I have inside the Paper UI two virtual switches, one for the KNX channel and one for the MQTT channel. Both of them are synchron and represent “ON” and “OFF” correct. And they can also used to switch the light.
- I have also one topic openHAB/KNX/1/4/16/command with “0” or “1” inside Mosquitto, the topic “openHAB/KNX/1/4/16/state” will not be written like I had hoped.
The main problem is, that I got over the command Topic the status, but can’t change the light over writing inside the Topic. I made some additional test today with a Node-RED installation. There I used also openHAB2 Nodes to connect to my installation. Writing here “0” and “1” did not switch the light, “ON” and “OFF” do this. So I read and convert in Node-RED the MQTT status from “0” to “OFF” and “1” to “ON” and could switch the lights over MQTT. But this needs to much rules. So I hoped to find a solution that openHAB do the same without Node-RED or other external help.
For me it is also not clear, why openHAB write himself “0” and “1” instead “ON” and “OFF” to MQTT.
Finally i hoped that I had described fully understandable what I have and what it is my problem. Be sure that I had read and searched a lot the last days, but I did not found the final solution.