Giter Club home page Giter Club logo

Comments (17)

zewelor avatar zewelor commented on July 22, 2024

There is some error with bluetooth adapter. From that logs and info, maybe you try to run 2 instances of the gateway ? One manually with ./gateway.py -d and second one via system service ?

from bt-mqtt-gateway.

kenand1970 avatar kenand1970 commented on July 22, 2024

Dear Zewelor,
Thank you very much your fast answer.
You are right, I run 2 instances.
How Can I test system service?
Becuse I do not see bt-mqtt-gateway data my nodred

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

I test only ./gateway -d , and if it works I just start system service. It should work then. You can check logs via: journalctl -xef -u bt-mqtt-gateway . And be sure to run only system service then. Maybe there will be something in he logs. Also I would suggest to use mosquitto_sub to monitor all of the mqtt messages, if anything is being sent.

from bt-mqtt-gateway.

kenand1970 avatar kenand1970 commented on July 22, 2024

Dear zewelor,
I stopped system service and I use onlly ./gateway -d

It woked in morning, but a bit later error message occured

pi@raspberrypi:/bt-mqtt-gateway $ sudo ./gateway.py -d
Starting
Setting LWT to: hostname/lwt_topic
WARNING: No module named 'pexpect'
Added: mithermometer with 300 seconds interval
Added: miflora with 300 seconds interval
Subscribing to: hostname/homeassistant/status
Updating all workers
[{'topic': 'mithermometer/living_room/temperature', 'payload': 22.3}, {'topic': 'mithermometer/living_room/humidity', 'payload': 53.1}, {'topic': 'mithermometer /living_room/battery', 'payload': 69}, {'topic': 'mithermometer/corridor/tempera ture', 'payload': 25.3}, {'topic': 'mithermometer/corridor/humidity', 'payload': 44.5}, {'topic': 'mithermometer/corridor/battery', 'payload': 98}]
[{'topic': 'miflora/herbs/temperature', 'payload': 21.0}, {'topic': 'miflora/her bs/moisture', 'payload': 48}, {'topic': 'miflora/herbs/light', 'payload': 164}, {'topic': 'miflora/herbs/conductivity', 'payload': 1137}, {'topic': 'miflora/her bs/battery', 'payload': 99}]
[{'topic': 'mithermometer/living_room/temperature', 'payload': 22.3}, {'topic': 'mithermometer/living_room/humidity', 'payload': 52.9}, {'topic': 'mithermometer /living_room/battery', 'payload': 69}]
[]
[]
[]
[]
[]
^CExiting allowing jobs to finish. If you need force exit use kill
pi@raspberrypi:
/bt-mqtt-gateway $ sudo ./gateway.py -d
Starting
Setting LWT to: hostname/lwt_topic
WARNING: No module named 'pexpect'
Added: mithermometer with 300 seconds interval
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 353, in ru n
wb.build(autobuilding=True)
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 380, in prepare _files
ignore_dependencies=self.ignore_dependencies))
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 666, in _prepar e_file
check_dist_requires_python(dist)
File "/usr/lib/python3/dist-packages/pip/utils/packaging.py", line 48, in chec k_dist_requires_python
feed_parser.feed(metadata)
File "/usr/lib/python3.5/email/feedparser.py", line 178, in feed
self._input.push(data)
File "/usr/lib/python3.5/email/feedparser.py", line 104, in push
self._partial.write(data)
TypeError: string argument expected, got 'NoneType'
Added: miflora with 300 seconds interval
Subscribing to: hostname/homeassistant/status
Updating all workers
[]
[]

from bt-mqtt-gateway.

kenand1970 avatar kenand1970 commented on July 22, 2024

Dear zewelor,
bt-mqtt gateway sometimes wokrs, sometimes do not work. (pi zero w)
I switched to miflora-mqtt daemon isntead. (https://github.com/ThomDietrich/miflora-mqtt-daemon)
miflora-mqtt works well everytime. But I have 3 Xiaomi Mijia LCD sensors also, that I sould prefer your bt-mqtt-gateway.....

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

Hi

For rpi zero w, be sure to use latest bluez ( https://blog.bluetooth.com/bluez-on-raspberry-pi-update ). From what I can see. miflora-mqtt-daemon uses the same miflora lib, but with different bluetooth backend ( https://github.com/ThomDietrich/miflora-mqtt-daemon/blob/master/miflora-mqtt-daemon.py#L220 ), which according to https://github.com/ChristianKuehnel/btlewrap#bluezgatttool-wrapper is less stable, but maybe in older version it works more stable ? I think best way would be to update bluez and try with it. If not I could make git branch with different btlewrap backend to test.

from bt-mqtt-gateway.

kenand1970 avatar kenand1970 commented on July 22, 2024

Dear zwelor,
I updated my pi zero w to bluez 5.50

I tested bt-mqtt-gateway with
sudo ./gateway.py -d

Starting
Setting LWT to: hostname/lwt_topic
WARNING: No module named 'pexpect'
Added: mithermometer with 120 seconds interval
Subscribing to: hostname/homeassistant/status
Updating all workers
[{'topic': 'mithermometer/corridor/temperature', 'payload': 23.4}, {'topic': 'mithermometer/corridor/humidity', 'payload': 50.2}, {'topic': 'mithermometer/corridor/battery', 'payload': 97}, {'topic': 'mithermometer/living_room/temperature', 'payload': 22.0}, {'topic': 'mithermometer/living_room/humidity', 'payload': 55.1}, {'topic': 'mithermometer/living_room/battery', 'payload': 69}]
[{'topic': 'mithermometer/corridor/temperature', 'payload': 23.2}, {'topic': 'mithermometer/corridor/humidity', 'payload': 49.8}, {'topic': 'mithermometer/corridor/battery', 'payload': 97}, {'topic': 'mithermometer/living_room/temperature', 'payload': 21.9}, {'topic': 'mithermometer/living_room/humidity', 'payload': 55.3}, {'topic': 'mithermometer/living_room/battery', 'payload': 69}]
[{'topic': 'mithermometer/corridor/temperature', 'payload': 23.3}, {'topic': 'mithermometer/corridor/humidity', 'payload': 49.9}, {'topic': 'mithermometer/corridor/battery', 'payload': 97}]
[]
[{'topic': 'mithermometer/corridor/temperature', 'payload': 23.3}, {'topic': 'mithermometer/corridor/humidity', 'payload': 50.1}, {'topic': 'mithermometer/corridor/battery', 'payload': 97}, {'topic': 'mithermometer/living_room/temperature', 'payload': 21.9},

I tray to subscribe message with mosquitto_sub an other teminal:

(for exapmle: topic mithermometer/corridor/temperature)

pi@raspberrypi:~ $ mosquitto_sub -h 192.168.1.123 -d -t mithermometer/corridor/temperature
Client mosqsub/764-raspberrypi sending CONNECT
Client mosqsub/764-raspberrypi received CONNACK
Client mosqsub/764-raspberrypi sending SUBSCRIBE (Mid: 1, Topic: mithermometer/corridor/temperature, QoS: 0)
Client mosqsub/764-raspberrypi received SUBACK
Subscribed (mid: 1): 0
Client mosqsub/764-raspberrypi sending PINGREQ
Client mosqsub/764-raspberrypi received PINGRESP
Client mosqsub/764-raspberrypi sending PINGREQ
Client mosqsub/764-raspberrypi received PINGRESP
Client mosqsub/764-raspberrypi sending PINGREQ
Client mosqsub/764-raspberrypi received PINGRESP
Client mosqsub/764-raspberrypi sending PINGREQ
Client mosqsub/764-raspberrypi received PINGRESP

But did not receive any mesage .......
Is it correct ?
mosquitto_sub -h 192.168.1.123 -d -t mithermometer/corridor/temperature

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

Try to set client_id in config.yaml . I think that helps sometimes. From that log everything looks fine.

from bt-mqtt-gateway.

kenand1970 avatar kenand1970 commented on July 22, 2024

Dear zewelor,
how can I set client_id?

This is my configuration.yaml

mqtt:
host: 192.168.1.123
port: 1883
username:
password:
topic_prefix: hostname
client_id: bt-mqtt-gateway
availability_topic: lwt_topic

manager:
topic_subscription:
update_all:
topic: homeassistant/status
payload: online
workers:
mithermometer:
args:
devices:
living_room: 4C:65:A8:D8:AD:A1
#corridor: 4C:65:A8:DC:53:82
topic_prefix: mithermometer
update_interval: 120

It's seems to me
sudo ./gateway.py -d

put data only the terminal, but I can not receive data from MQTT

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

Delete username and password from config. Also for mosquitto_sub try topic -t \# ( listen to all topic ). As you've left topic_prefix, the actual topic is hostname/mithermometer/corridor/temperature , thats why when you filter to only mithermometer/corridor/temperature you don't see anything. Delete topic_prefix also, from the config.

This should print all messages.
mosquitto_sub -h 192.168.1.123 -d -t \#

from bt-mqtt-gateway.

kenand1970 avatar kenand1970 commented on July 22, 2024

Dear zeweleor,

Thank you very much your patience, and your help.
It works for me at now.

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

Great to hear that. Maybe you can propose some README improvements, to make it easier to setup ?

from bt-mqtt-gateway.

kenand1970 avatar kenand1970 commented on July 22, 2024

Dear zewelor,

Many user use this topic for to compile Bluez
https://www.domoticz.com/wiki/Mi_Flora_Bluetooth_LE
This use Bluez 5.44 only
Link newest bluez description:
https://www.bluetooth.com/~/media/files/developer/t1804_how%20to%20set%20up%20bluez_lfc_final.ashx?la=en

And suggestion to delete topic_prefix in config.yaml also helped for me
and
mosquitto_sub -h localhost -d -t # command also help for me to test MQTT messages

Regars
Andras

from bt-mqtt-gateway.

kenand1970 avatar kenand1970 commented on July 22, 2024

DEar zwelor,

Sorry but I rexeived new error today

pi@raspberrypi:~ $ sudo systemctl status bt-mqtt-gateway
● bt-mqtt-gateway.service - Bluetooth MQTT gateway
Loaded: loaded (/etc/systemd/system/bt-mqtt-gateway.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Wed 2019-01-30 19:03:07 CET; 4s ago
Docs: https://github.com/zewelor/bt-mqtt-gateway
Process: 463 ExecStart=/home/pi/bt-mqtt-gateway/gateway.py (code=killed, signal=TERM)
Main PID: 463 (code=killed, signal=TERM)

jan 30 19:00:12 raspberrypi gateway.py[463]: self.fill_cache()
jan 30 19:00:12 raspberrypi gateway.py[463]: File "/usr/local/lib/python3.5/dist-packages/mithermometer/mithermometer_poller.py", line 67,
jan 30 19:00:12 raspberrypi gateway.py[463]: with self._bt_interface.connect(self._mac) as connection:
jan 30 19:00:12 raspberrypi gateway.py[463]: File "/usr/local/lib/python3.5/dist-packages/btlewrap/base.py", line 44, in enter
jan 30 19:00:12 raspberrypi gateway.py[463]: self._backend.connect(self._mac)
jan 30 19:00:12 raspberrypi gateway.py[463]: File "/usr/local/lib/python3.5/dist-packages/btlewrap/bluepy.py", line 32, in _func_wrapper
jan 30 19:00:12 raspberrypi gateway.py[463]: raise BluetoothBackendException() from last_error
jan 30 19:00:12 raspberrypi gateway.py[463]: btlewrap.base.BluetoothBackendException

After stop and start gatewy service it works again

pi@raspberrypi:~ $ sudo systemctl stop bt-mqtt-gateway
pi@raspberrypi:~ $ sudo systemctl start bt-mqtt-gateway
pi@raspberrypi:~ $ sudo systemctl status bt-mqtt-gateway
● bt-mqtt-gateway.service - Bluetooth MQTT gateway
Loaded: loaded (/etc/systemd/system/bt-mqtt-gateway.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-01-30 19:03:21 CET; 3s ago
Docs: https://github.com/zewelor/bt-mqtt-gateway
Main PID: 12398 (python3)
CGroup: /system.slice/bt-mqtt-gateway.service
└─12398 python3 /home/pi/bt-mqtt-gateway/gateway.py

jan 30 19:03:21 raspberrypi systemd[1]: Started Bluetooth MQTT gateway.

from bt-mqtt-gateway.

zewelor avatar zewelor commented on July 22, 2024

After such error, you dont need to restart gateway. All errors should be catched, and on another interval time, gateway will make another read. I got usually few per day ( i got 7 devices ). You can just ignore it. Yesterday I've made small update and added "-q" option to skip printing that errors, you can add it in the sevice file to keep logs less verbose.

from bt-mqtt-gateway.

kenand1970 avatar kenand1970 commented on July 22, 2024

Thank you

from bt-mqtt-gateway.

kenand1970 avatar kenand1970 commented on July 22, 2024

Thank you.
I will increase update_interval.

from bt-mqtt-gateway.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.