Hi
You’ll have to excuse me as I’m just getting into this stuff but I’ve got a problem with duplicate items appearing in my MQTT queue.
So… What I’m trying to achieve is this:
- I move a switch on OpenHab and an entry is placed in the MQTT queue for that action.
- Something else can enter the action into the MQTT queue and OpenHab will reflect that change.
I currently have the following openHab config:
Items file:
Switch mqttSwitch {mqtt=">[remotepi:/myhouse/office/light:command:ON:1],>[remotepi:/myhouse/office/light:command:OFF:0]"} String mqttMessage { mqtt="<[remotepi:/myhouse/office/light:state:default]" }
Sitemap:
Frame label="MQTT" { Switch item=mqttSwitch }
Rules:
rule "MqttMessageChanged" when Item mqttMessage changed then switch mqttMessage.state { case '1': mqttSwitch.sendCommand("ON") case '0': mqttSwitch.sendCommand("OFF") } end
It all works lovely apart from the duplicated messages:
$ mosquitto_sub -t '/myhouse/#' 1 1 0 0
is one on/off of the switch and exactly the same happens when I issue these:
$ mosquitto_pub -t /myhouse/office/light -m '1' $ mosquitto_pub -t /myhouse/office/light -m '0'
$ mosquitto_sub -t '/myhouse/#' 1 1 0 0
Thanks for your help!