Dimmer item with MQTT and multiple triggers

Hello everybody, I’m trying to connect my dimmer item with a physical switch on my ESP via MQTT but I’m having some strange behavior. This is how my item is defined and it’s representation in sitemap:

home.items file

Dimmer BedroomBedAmbientLightDimmer "Light intensity [%d %%]" (gBedroom) {mqtt="<[oh2mqtt:bedled/intensity/value:state:default], >[oh2mqtt:bedled/intensity:command:*:default]"}

home.sitemap file

Slider item=BedroomBedAmbientLightDimmer

What actually happens is that when I change the value of the dimmer in PaperUI, I get two MQTT requests sent to my ESP, one after another. Also, if i change the value on my ESP via physical knob, ESP send a value to openHab, but then openHab sends the same value back to ESP…

I have no rules defined. What am I doing wrong?

Anyone? :confused:

hi,

Have you tried to use: autoupdate=“false” ?

Switch writeLightSwitch2 {mqtt=">[mosquitto:myhouse/office/light2:command:OFF:0],>[mosquitto:myhouse/office/light2:command:ON:1],<[mosquitto:myhouse/office/light2:state:MAP(binary.map)]", autoupdate="false"}

Hi Marcin, yes, I have but in that case, the UI isn’t updated (at least not without a rule). I’ve inspected event log and found out that when I move the slider in the UI, it behaves as two event (onMouseDown and onMouseUp).

Btw, I managed to prevent openHab from retriggering the MQTT msg (instead of state, i was subscribed to a command) back to ESP. But now this double publishing is bothering me as:

  1. it sends another (useless) msg and just adds more work for everybody
  2. values that are sent from the dimmer could be different: ie. first msg would have a dimmer value of 15 and second msg could be, let’s say 55 - and you see that that could be a serious problem as ESP receiving the msg will first set LED brightness to 15% and immediatelly after that set it to 55%…

Ok, i found out that only PaperUI triggers multiple MQTT requests so i assume that is related to it only…Working as expected from the iOS app… haven’t tested other browser based UIs…

If i catch some time to analyze PaperUI, I’ll try to fix it and create a PR on git…