zewelor / bt-mqtt-gateway

A simple Python script which provides a Bluetooth to MQTT gateway, easily extensible via custom workers. See https://github.com/zewelor/bt-mqtt-gateway/wiki for more information.
MIT License
549 stars 116 forks source link

Missing MQTT messages #262

Closed adamcodemaker closed 1 year ago

adamcodemaker commented 1 year ago

I have a config with one thermostat. Sometimes the manager does not receive mqtt messages. When I send message to mqtt broker to set temperature to some value there is no debug message at all.

image

Just like it was ignored or something. There should be loge like this. 2022-09-17 21:42:17,028 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:193:_on_command_wrapper - Received command for thermostat on thermostat/office-biuro/target_temperature/set: b'17' Sometimes message is received but sometimes not. I don't know why. Manager should receive every message from mqtt broker. I use my mqtt broker (Eclipse Mosquitto) for years without any problems so the broker is ok. Even with messages with retain flag are missing.

To Reproduce Steps to reproduce the behavior:

  1. Try to send message to change target temperature
  2. Do it couple of times
  3. Observe that some messages are missing in logs

Expected behavior Every message from mqtt broker should be received by manager and handled properly.

Config

mqtt:
  host: 192.168.0.90
  port: 1883
  username: xxx
  password: yyy
  client_id: bt-mqtt-gateway
  availability_topic: lwt_topic

manager:
  sensor_config:
    topic: homeassistant
    retain: true
  topic_subscription:
    update_all:
      topic: homeassistant/status
      payload: online
  command_timeout: 25
  update_retries: 3
  workers:
    thermostat:
      args:
        devices:
          office-biuro:
            mac: XX:XX:XX:XX:XX:XX
            discovery_temperature_topic: bt-scanner/sensor/x1_temperature/state
        topic_prefix: thermostat
      topic_subscription: thermostat/+/+/set
      update_interval: 60

Server (please complete the following information):

adamcodemaker commented 1 year ago

I ran mosquitto_sub and subscribed to thermostat/office-biuro/target_temperature/set and it received every single message that I send so network is not an issue.

adamcodemaker commented 1 year ago

Problem was in my setup. I had two raspbery pi in one network with single mqtt broker. Both had the same client-id.

I changed client-id and added topic_prefix in each raspberry pi and everything works as expected now.