MQTT item gets updated twice with different values by the same message

Hi,
This is likely just another configuration mistake but I just can’t find it.

I have a mqtt item that first gets updated twice by the same message. First with the wrong value, then shortly after it is updated with the correct value.
I’ve been staring me blind on the files and I can’t understand why this is happening. I use a file based set-up and the THING and ITEM files are posted below.

Here’s the issue in the log. Notice how the item “tasmota_55C3A8_Lux” first gets the value that “tasmota_55C3A8_Temp” should get. Then later gets its own value.

2021-08-22 16:34:37.276 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'tasmota_55C3A8_Lux' changed from 2155 lx to 30.2 lx
2021-08-22 16:34:45.399 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'tasmota_55C3A8_Lux' changed from 30.2 lx to 30 lx
2021-08-22 16:34:45.401 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'tasmota_55C3A8_Temp' changed from 30.2 °C to 30 °C
2021-08-22 16:34:45.403 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'tasmota_55C3A8_Lux' changed from 30 lx to 2047 lx

The MQTT payload that get’s published to the broker looks like this. Although it’s not the actual message but the format is right.

MQTT payload:

{
  "Time": "2021-08-22T15:30:15",
  "BMP280": {
    "Temperature": 30.8,
    "Pressure": -17
  },
  "BH1750": {
    "Illuminance": 2857
  },
  "PressureUnit": "hPa",
  "TempUnit": "C"
}

Don’t worry about the negative pressure value. I bought the BMP280-sensor on Amazon. :roll_eyes:

THINGS - File:

Bridge mqtt:broker:MQTTBroker188 "MQTTBroker188" [ host ="192.168.1.188", secure=false, username="******", password="******", clientID ="openHABClient" ]
{
    // Lux and temp sensor
    Thing topic tasmota_55C3A8 "tasmota_55C3A8" [ availabilityTopic="tele/tasmota_55C3A8/LWT", payloadAvailable="Online", payloadNotAvailable="Offline"] {
    Channels:
        Type number : tasmota_55C3A8_temperature    "tasmota_55C3A8 Temperature"    [ stateTopic = "tele/tasmota_55C3A8/SENSOR", transformationPattern = "JSONPATH:$.BMP280.Temperature" ]
        Type number : tasmota_55C3A8_lux            "tasmota_55C3A8 Illuminance"    [ stateTopic = "tele/tasmota_55C3A8/SENSOR", transformationPattern = "JSONPATH:$.BH1750.Illuminance" ]
    }
}

I’ve tried a different transformation patterns but it makes no difference.

REGEX:(.*Illuminance.*)∩JSONPATH:$.BH1750.Illuminance 

ITEM-file:

Number:Temperature    tasmota_55C3A8_Temp   "tasmota_55C3A8 Temperature [%.1f °C]" <temperature>   [ "Temperature", "Measurement" ]  { channel="mqtt:topic:MQTTBroker188:tasmota_55C3A8:tasmota_55C3A8_temperature" }
Number:Dimensionless  tasmota_55C3A8_Lux    "tasmota_55C3A8 Lux [%.1f lx]"                         [ "Light", "Measurement" ]        { channel="mqtt:topic:MQTTBroker188:tasmota_55C3A8:tasmota_55C3A8_lux" }

I run OH3.1 on a Raspberry Pi 4 with OpenHabian

Have you tried restarting openHAB at all? Sometimes changes in Things files don’t get properly picked up by openHAB at runtime.

2 Likes

It won’t be your double-update of itself, but …
I’m surprised that accepts any update with lux units.
Number:Illuminance
Maybe it’s a clue that this Item is defined twice somewhere - you’ll get one Item but perhaps two channel links.

1 Like

Well, no…

sudo systemctl restart openhab

…but it did the trick. Thanks!
I will have to keep a lookout for that in the future since I mainly use text based config.

Thanks! I hadn’t notised that I could set that. I’ve updated the file. ​