Ikea Tradfri setting dimmer value sets a different value

Hi there!
I am having some weird issue with the Ikea Tradfri binding. Actually I am not entirely sure if the issue is with the Ikea binding itself or with something else…

I am running the latest Openhabian version with Opnehab 2.4.0-1.

The issue appears when I want to control my Ikea Tradfri bulb (1000lm dimmable only LED) through the Tradfri gateway.

This is my item definition:

Dimmer Zgoraj_DnevnaSoba_Luc_Dimmer "Luč glavna [%d%%]" <light> (Zgoraj_DnevnaSoba) [Lighting] {channel="tradfri:0100:gwa0c9a0d98edb:65542:brightness"}

And this is my rule for controlling the light using an RF remote:

rule "Dnevna Soba RF received"
when
  Item Hiska_RF_bridge_Received received update
then
  if (Hiska_RF_bridge_Received.state == "982BC2") {
    // Button A
    if (Zgoraj_DnevnaSoba_Luc_Dimmer.state > 0) {
      Zgoraj_DnevnaSoba_Luc_Dimmer.sendCommand(OFF)
    } else {
      Zgoraj_DnevnaSoba_Luc_Dimmer.sendCommand(ON)
    }
  } else if (Hiska_RF_bridge_Received.state == "982BC8") {
    // Button B
  } else if (Hiska_RF_bridge_Received.state == "982BC1") {
    // Button C
    val numericState = Zgoraj_DnevnaSoba_Luc_Dimmer.state as DecimalType
    var numberToSubstract = numericState.intValue() % 10
    if (numberToSubstract <= 0) {
      numberToSubstract = 10
    }

    var newValue = numericState.intValue() - numberToSubstract
    if (newValue < 0) {
      newValue = 0
    }
    Zgoraj_DnevnaSoba_Luc_Dimmer.sendCommand(newValue)
  } else if (Hiska_RF_bridge_Received.state == "982BC4") {
    // Button D
    val numericState = Zgoraj_DnevnaSoba_Luc_Dimmer.state as DecimalType
    var newValue = numericState.intValue() - (numericState.intValue() % 10) + 10
    if (newValue > 100) {
      newValue = 100
    }
    Zgoraj_DnevnaSoba_Luc_Dimmer.sendCommand(newValue)
  }
end

The issue happens when using buttons C and D that are supposed to change the brightness ±10% (rounding to nearest 10).

Here is an example what happens (the initial value was 50):

2019-01-11 22:48:11.200 [vent.ItemStateChangedEvent] - Hiska_RF_bridge_Received changed from 982BC4 to 982BC1
2019-01-11 22:48:11.230 [ome.event.ItemCommandEvent] - Item 'Zgoraj_DnevnaSoba_Luc_Dimmer' received command 40
2019-01-11 22:48:11.235 [nt.ItemStatePredictedEvent] - Zgoraj_DnevnaSoba_Luc_Dimmer predicted to become 40
2019-01-11 22:48:11.255 [vent.ItemStateChangedEvent] - Zgoraj_DnevnaSoba_Luc_Dimmer changed from 50 to 40
2019-01-11 22:48:11.277 [vent.ItemStateChangedEvent] - Zgoraj_DnevnaSoba_Luc_Dimmer changed from 40 to 41

Basically it keeps adding that 1 for some weird reason. But not always. Almost always when the value is below 50. Above 50 it sometimes works fine (at least more often than when it is under 50). Logging the value that gets sent showed that the correct value gets supplied to SendCommand and it isn’t happening twice or anything like that.

I am not using Zgoraj_DnevnaSoba_Luc_Dimmer in any other rule or anything like that. And what is even weirder… this happens if I use BasicUI to change the slider value as well.

2019-01-11 22:49:44.484 [ome.event.ItemCommandEvent] - Item 'Zgoraj_DnevnaSoba_Luc_Dimmer' received command 29
2019-01-11 22:49:44.491 [nt.ItemStatePredictedEvent] - Zgoraj_DnevnaSoba_Luc_Dimmer predicted to become 29
2019-01-11 22:49:44.502 [vent.ItemStateChangedEvent] - Zgoraj_DnevnaSoba_Luc_Dimmer changed from 41 to 29
2019-01-11 22:49:44.525 [vent.ItemStateChangedEvent] - Zgoraj_DnevnaSoba_Luc_Dimmer changed from 29 to 30

Any ideas on what is going on?

The device is sending back the actual state after the update. It just happen that it’s not that accurate and out by one %. You shouldn’t be able to tell the difference visually

Oh. I didn’t even think about that. It’s just annoying if you look and the number and it’s not properly nice and rounded :smile:.