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

blescanmulti worker not publishing to MQTT #258

Closed danhpham1510 closed 1 year ago

danhpham1510 commented 1 year ago

Describe the bug When I run the blescanmulti worker example, it produces the payload but it's not sending anything to mqtt. It still sends online to lwt_topic image

To Reproduce Run gateway.py in debug mode with blescanmulti worker.

Expected behavior I expect it to send status to MQTT.

Config mqtt: host: secret port: secret username: secret password: secret

ca_cert: /etc/ssl/certs/ca-certificates.crt # Uncomment to enable MQTT TLS, update path to appropriate location.

ca_verify: False # Verify TLS certificate chain and host, disable for testing with self-signed certificates, default to True

client_cert: mosq_client.crt # If client_cert and client_key are specified, MQTT uses client certificate authentication instead of username + password

client_key: mosq_client.key

topic_prefix: btmqtt # All messages will have that prefix added, remove if you dont need this. 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: 35 # Timeout for worker operations. Can be removed if the default of 35 seconds is sufficient. command_retries: 0 # Number of retries for worker commands. Default is 0. Might not be supported for all workers. update_retries: 0 # Number of retries for worker updates. Default is 0. Might not be supported for all workers. workers:

mysensors:

#   command_timeout: 35       # Optional override of globally set command_timeout.
#   command_retries: 0        # Optional override of globally set command_retries.
#   update_retries: 0         # Optional override of globally set update_retries.
#   args:
#     port: /dev/ttyUSB0
#     baudrate: 9600
#     topic_prefix: mysensors/out
# thermostat:
#   args:
#     devices:
#       bedroom: 00:11:22:33:44:55  # Simple format
#       living_room:                # Extended format with additional configuration
#         mac: 00:11:22:33:44:55
#         discovery_temperature_topic: some/sensor/with/temperature       # Optional current_temperature_topic for HASS discovery
#         discovery_temperature_template: "{{ value_json.temperature }}"  # Optional current_temperature_template for HASS discovery
#     topic_prefix: thermostat
#   topic_subscription: thermostat/+/+/set
#   update_interval: 60
# miscale:
#   args:
#     mac: 00:11:22:33:44:55
#     topic_prefix: miscale
#     users:                         # Used for recognizing multiple people, as well as for decoding body metrics! (Optional)
#       Alex:                        # Name (used in MQTT to define a user topic)
#         weight_template:           # The weight template that the user will be tracked by!
#           min: 70
#           max: 90
#         sex: male                  # Sex (male or female)
#         height: 185                # Height (in cm)
#         dob: 2000-01-11            # DOB (in yyyy-mm-dd format)
#       Olivia:
#         weight_template:
#           min: 30
#           max: 60
#         sex: female
#         height: 165
#         dob: 2000-02-22
#   update_interval: 1800
# linakdesk:
#   args:
#     mac: 00:11:22:33:44:55
#     topic_prefix: linak_desk
#   update_interval: 1800
# miflora:
#   args:
#     adapter: hci0
#     devices:
#       herbs: 00:11:22:33:44:55
#     topic_prefix: miflora
#     per_device_timeout: 6            # Optional override of globally set per_device_timeout.
#   update_interval: 300
# mithermometer:
#   args:
#     devices:
#       living_room: 00:11:22:33:44:55
#     topic_prefix: mithermometer
#     per_device_timeout: 6            # Optional override of globally set per_device_timeout.
#   update_interval: 300
 blescanmulti:
   args:
     devices:
       beacon: 60:10:a6:af:2b:62
       beacon1: c8:19:08:54:99:4a
       beacon2: c3:4e:7b:64:48:e6
     topic_prefix: plzwork
     available_payload: home
     unavailable_payload: not_home
     available_timeout: 0
     unavailable_timeout: 15
     scan_timeout: 10
     scan_passive: true
   update_interval: 60

Debug gateway logs 2022-07-14 09:01:46,344 DEBUG bt-mqtt-gw.workers_manager workers_manager.py:57:execute - Execution result of command BlescanmultiWorker.status_update: [{'topic': 'plzwork/presence/beacon1', 'payload': 'home'}, {'topic': 'plzwork/presence/beacon1/rssi', 'payload': '-66'}]

Server (please complete the following information):