Send mqtt message 2 times


I’m having trouble may be with rules. The objective is to archive the following:
I get some values for Hue light, BLE things, and some via MQTT.
But when I trying sending these values to my web app via openHAB, they send 2 mqtt message(send 2 times).
Some of these send 4 mqtt message(send 4 times).
My idea about rules looks like that:

rule "LightGroup1_Power_OHtoUI"
    Item LightGroup1_Power changed
    var time = new DateTimeType().format("%1$tY-%1$tm-%1$tdT%1$tT%1tZ")
    if(LightGroup1_Power.state == OFF){
        LightGroup1_Power_Command_ui.sendCommand('{"button":false,"ts":"' + time + '"}')
        LightGroup1_Power_Command_ui.sendCommand('{"button":true,"ts":"' + time + '"}')

What am I missing here?

Thanks in advance for any clues on getting that work.


I suppose the first thing to check is how often your rule gets triggered. Look in your events.log to see when that Item changes. If it is a Group type Item, it may not be doing what you expect.

@rossko57 sorry, my rules of question is one example.
All rules send 2 messages (2times) regardless whether thing or group.
I will check log.
Thank you.

Once again, refer to your events.log

Guessing that Item is linked somehow to an MQTT channel, how may commands does it get sent?

If that looks sensible, then next to look at the mystery MQTT channel configuration.

@rossko57 I have checked events.log.
But it looks like working correctly.(received, changed once)
I will check my mystery MQTT channel configuration.

Sorry, my mistake.
It sended, and received 2 messages(2 times) in events.log.

What does that look like? You can’t see any messages in your events.log, only Items changing (which should tell you about your rules being run) or being sent commands (which should tell you about what your rules are doing).

It looks like that:

2022-02-24 23:28:57.304 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'DoorLock_Lock_Command_ui' received command {"button":false,"ts":"2022-02-24T23:28:57+09:00"}
2022-02-24 23:28:57.308 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'DoorLock_Lock_Command_ui' predicted to become {"button":false,"ts":"2022-02-24T23:28:57+09:00"}
2022-02-24 23:28:57.313 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'DoorLock_Lock_Command_ui' changed from {"button":true,"ts":"2022-02-24T23:25:56+09:00"} to {"button":false,"ts":"2022-02-24T23:28:57+09:00"}
2022-02-24 23:28:57.334 [INFO ] [openhab.event.ItemCommandEvent      ] - Item 'DoorLock_Lock_Command_ui' received command {"button":false,"ts":"2022-02-24T23:28:57+09:00"}
2022-02-24 23:28:57.338 [INFO ] [penhab.event.ItemStatePredictedEvent] - Item 'DoorLock_Lock_Command_ui' predicted to become {"button":false,"ts":"2022-02-24T23:28:57+09:00"}

It looks like being received same messages 2 times.

Looks like this Item was sent commands twice, yes. I guess that has something to do with MQTT messages, we can’t tell from here.

So looking back before that, what triggers the rule that sends those commands? How often does that happen?


This is a key topic, but every topic receives the message twice.
In other words, I have received the message twice regardless of the trigger.
Why …?
(Sorry for the late reply.)

No idea.

I don’t know what that means.
Does that have anything to do with the log excerpt you showed before -

where some Item gets two similar commands? I that Item is linked to MQTT by means that you are still keeping secret, then those two commands will send two messages.

The puzzle then is about two commands, and we don’t care about MQTT.
Can we see the rule that makes that happen?
Can we see how often that rule runs?


Thank you.
I will check how many times my rules is called.