Some Mqtt topics not being written when switching multiple toggle switches at once

I’m having this strange issue when i try to switch multiple toggle switches at once in my lovelace dashboard. Some of the toggle switches move and some stay in their old position.
The toggle switches I’m talking about are all MQTT controls.

The image below illustrates what happens:
I switch upper “all” toggle switch that normally controls all lower toggle switches, but some of them stay in their old position. It seems a bit random which will work and which will stay.
When i check the MQTT Explorer, it seems like the MQTT-topic has effectively not been set by HA.
When i switch the switches one by one, all works fine!

The MQTT controls (toggle switches) are added by automatic MQTT discovery, their config topic data looks like this:

  "name": "i_Slaapkamer1_AircoAan",
  "object_id": "UL103",
  "unique_id": "i_Slaapkamer1_AircoAan",
  "device": {
    "identifiers": "QB switch",
    "name": "QB switch",
    "model": "QB switch",
    "manufacturer": "WK",
    "sw_version": "2.2.3"
  "retain": false,
  "qos": 2,
  "state_topic": "cloudapp/QBUSMQTTGW/UL1/UL103/state",
  "value_template": "{{value_json[\"properties\"][\"value\"] if value_json[\"properties\"][\"value\"] is defined else (states(entity_id)) }}",
  "state_on": true,
  "state_off": false,
  "command_topic": "cloudapp/QBUSMQTTGW/UL1/UL103/setState",
  "payload_on": "{\"id\":\"UL103\",\"type\": \"state\",\"properties\": {\"value\": true}}",
  "payload_off": "{\"id\":\"UL103\",\"type\": \"state\",\"properties\": {\"value\": false}}"

I’m running HA version 2023.8.3 in a Docker container
I’m running an updated version of the Mosquitto broker also in a Docker container.
All runs on a raspberry pi 4 running raspios_lite_arm64

I think I have checked the logs of HA and Mosquitto, but i don’t seem to see errors about missing messages… Is there another place i can look? Is there a way to trace what happens?

When i try to do the same in node red, straight to the MQTT, all of the outputs always work:


Example of the “Debug TurnOn” the function that sets up the MQTT message:

In case anybodye else stumbles upon this issue:

The problem was that the topics were posted on the MQTT broker with quality of service (QoS) set to 2.
Because of this messages were dropped when sending multiple messages at once.

I guess in NodeRed the messages were sent sequentially and therefor worked even with QoS 2.

The issue was solved by setting the QoS to 0 when posting the topics on the MQTT Broker.