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
550 stars 117 forks source link

hardware compatibility #252

Open jerome6994 opened 2 years ago

jerome6994 commented 2 years ago

good evening a question are the NUT mini, Nut Find 3, Tile, somfy badge compatible with bt2mqtt? Thank you

zewelor commented 2 years ago

Hi

There is generic ble scanner worker. Probably you can use it: https://github.com/zewelor/bt-mqtt-gateway/blob/master/workers/blescanmulti.py https://github.com/zewelor/bt-mqtt-gateway/blob/master/config.yaml.example#L84

jerome6994 commented 2 years ago

hello thank you for the answer I looked and I did this: `mqtt: host: 192.168.1.140 port: 1883

username: user

password: password

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: bt2mqtt # 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

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

miflora:

args:

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

blescanmulti:
  args:
    devices:
      nut01: F0:2C:AC:84:4C:31
      nut02: D3:E2:D7:F9:5E:D9
    topic_prefix: blescan
    available_payload: home
    unavailable_payload: not_home
    available_timeout: 0
    unavailable_timeout: 60
    scan_timeout: 10
    scan_passive: true
  update_interval: 60

`

It seems to give a few things but in my test I have 2 nut find 3 and I only see one on MQTT Explorer image

When I do sudo ./gateway.py

I have an error on the opening of the serial port ttyUSB0 that I cannot correct image

Afterwards, during the deployment I change the path for the user image

Then when I run the service I get this error again image

So when restarting my VM there will no longer be the active service

thanks a lot for your help

zewelor commented 2 years ago

In workers section of the config, leave only blescanmulti worker, delete everything else, if you don't want to use it ( you probably don't need anything else for now ).

jerome6994 commented 2 years ago

sorry for the formatting of the code block there must be symbols in it badly recognized

yes I deleted or commented everything for future use like Miscale

on the other hand I do not understand the errors related to the serial port and the service which does not want to remain active. if my VM is stopped and restart I lose bt2mqtt and I have to restart by hand

zewelor commented 2 years ago

serial port is used AFAIK only by mysensors worker, from pasted config, looks like you got it still on. Delete it and it should run

jerome6994 commented 2 years ago

Hello Indeed I left my sensor Removing more error is better :) However, I can't get the service to activate.

image

image

image

zewelor commented 2 years ago

Run it without service to get full logs.

jerome6994 commented 2 years ago

I launched this sudo ./gateway.py -d

image

zewelor commented 2 years ago

Looks good. Not sure why service version doesn't start. I think you could try to add "-d" on the end of this line, maybe it will show some error: https://github.com/zewelor/bt-mqtt-gateway/blob/master/bt-mqtt-gateway.service#L9.

EDIT: Or maybe this: https://unix.stackexchange.com/questions/225401/how-to-see-full-log-from-systemctl-status-service

jerome6994 commented 2 years ago

I started all over again I have this command which gives me image

image

zewelor commented 2 years ago

You probably missed this step:

sudo pip3 install -r requirements.txt

Also I would suggest try docker router, as it should be easier to work with and maintain.

jerome6994 commented 2 years ago

good evening I ordered it, it's weird!

I can't make it despite the advice docker I don't have at all I only have VMs behind this test I want to implement the solution on several pi zero to mesh the house better

zewelor commented 2 years ago

I've looked at venv instructions and fixed them a bit. I'm not using this method so don't have much experience. If you want to mesh home with some bluetooth tags to see where is someone etc. I would recommend use some esp32 board with software like https://esphome.io/ or https://tasmota.github.io/docs/ or maybe something like this: https://home-assistant-guide.com/2021/09/09/is-espresense-the-successor-to-esp32-mqtt-room-weve-been-waiting-for/. Having few rpi zero is a headache to support them in long run. You got whole linux system running + possible problems with sdcard wearing after a lot of writes ( unless you configure os as read only ).

I would go with esphome route, you can probably use it with mqtt only without Home Assistant even.