algirdasc / xiaomi-ble-mqtt Goto Github PK
View Code? Open in Web Editor NEWXiaomi BLE Temperature and Humidity Sensor Bluetooth To MQTT gateway
Xiaomi BLE Temperature and Humidity Sensor Bluetooth To MQTT gateway
Hello
I dont see to work the code
I try to put all the code in all of the folders
Python version
Raspbery PI 3b+ With Raspberian
`Traceback (most recent call last):
File "/home/pi/mitemp/data-read.py", line 2, in
from mitemp.mitemp_bt.mitemp_bt_poller import MiTempBtPoller
File "/home/pi/mitemp/mitemp/mitemp_bt/mitemp_bt_poller.py", line 8, in
from btlewrap.base import BluetoothInterface, BluetoothBackendException
ImportError: No module named 'btlewrap.base'
`
Hi,
I have tested with 1 device, it works perfectly.
I have tested with 2 devices and it crashes (content of "xiaomi-ble.log"):
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/btlewrap/bluepy.py", line 26, in _func_wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/btlewrap/bluepy.py", line 55, in connect
self._peripheral = Peripheral(mac, iface=iface)
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 391, in init
self._connect(deviceAddr, addrType, iface)
File "/usr/local/lib/python3.5/dist-packages/bluepy/btle.py", line 439, in _connect
raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 58:2D:34:32:D5:BD, addr type: public
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/pi/xiaomi-ble-mqtt/data-read.py", line 48, in
temperature = poller.parameter_value(MI_TEMPERATURE)
File "/usr/local/lib/python3.5/dist-packages/mitemp_bt/mitemp_bt_poller.py", line 125, in parameter_value
self.fill_cache()
File "/usr/local/lib/python3.5/dist-packages/mitemp_bt/mitemp_bt_poller.py", line 59, in fill_cache
self.firmware_version()
File "/usr/local/lib/python3.5/dist-packages/mitemp_bt/mitemp_bt_poller.py", line 89, in firmware_version
with self._bt_interface.connect(self._mac) as connection:
File "/usr/local/lib/python3.5/dist-packages/btlewrap/base.py", line 44, in enter
self._backend.connect(self._mac)
File "/usr/local/lib/python3.5/dist-packages/btlewrap/bluepy.py", line 32, in _func_wrapper
raise BluetoothBackendException() from last_error
btlewrap.base.BluetoothBackendException
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/pi/xiaomi-ble-mqtt/data-read.py", line 102, in
except bluepy.btle.BTLEException:
NameError: name 'bluepy' is not defined
Content of "devices.ini":
[living_room]
device_mac=58:2D:34:32:D5:BD
topic=ble/living
average=3
[bad]
device_mac=58:2D:34:32:D5:2E
topic=ble/bad
average=3
Any help?
Thanks!
Hello,
i have install your script but when i started there is no mitemp_bt_poller.py to find. Where can i get this, or what i have to install?
Take a look at the MQTT file that seems to have your own password.
Hello!
When I try to run python3 data-read.py
, I see this in the console:
Traceback (most recent call last): File "data-read.py", line 3, in <module> from mitemp.mitemp_bt.mitemp_bt_poller import MiTempBtPoller File "/home/pi/xiaomi-ble-mqtt/mitemp/mitemp_bt/mitemp_bt_poller.py", line 8, in <module> from btlewrap.base import BluetoothInterface, BluetoothBackendException File "/home/pi/.local/lib/python3.5/site-packages/btlewrap/__init__.py", line 23, in <module> from btlewrap.gatttool import ( File "/home/pi/.local/lib/python3.5/site-packages/btlewrap/gatttool.py", line 44 ): ^ SyntaxError: invalid syntax
Any help will be great. Thanks for your time!
%Debug data-read.py
Error polling device frigo: could not convert string to float: '3.5\x00'
Thanks
On Ubuntu 20.04 on Raspberry Pi I had to install:
apt-get install libglib2.0-dev pi-bluetooth
pip3 install btlewrap
Hi again,
I have installed your script on another device with an external BT dongle and with the same configuration (for devices), I get the following error:
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/btlewrap/bluepy.py", line 26, in _func_wrapper
return func(*args, **kwargs)
File "/usr/lib/python3.7/site-packages/btlewrap/bluepy.py", line 55, in connect
self._peripheral = Peripheral(mac, iface=iface)
File "/btle.py", line 391, in init
File "/btle.py", line 439, in _connect
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 58:2D:34:32:D5:2E, addr type: public
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "data-read.py", line 49, in
temperature = poller.parameter_value(MI_TEMPERATURE)
File "/usr/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 125, in parameter_value
self.fill_cache()
File "/usr/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 59, in fill_cache
self.firmware_version()
File "/usr/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 89, in firmware_version
with self._bt_interface.connect(self._mac) as connection:
File "/usr/lib/python3.7/site-packages/btlewrap/base.py", line 44, in enter
self._backend.connect(self._mac)
File "/usr/lib/python3.7/site-packages/btlewrap/bluepy.py", line 32, in _func_wrapper
raise BluetoothBackendException() from last_error
btlewrap.base.BluetoothBackendException
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/btlewrap/bluepy.py", line 26, in _func_wrapper
return func(*args, **kwargs)
File "/usr/lib/python3.7/site-packages/btlewrap/bluepy.py", line 55, in connect
self._peripheral = Peripheral(mac, iface=iface)
File "/btle.py", line 391, in init
File "/btle.py", line 439, in _connect
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 58:2D:34:32:D5:BD, addr type: public
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "data-read.py", line 49, in
temperature = poller.parameter_value(MI_TEMPERATURE)
File "/usr/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 125, in parameter_value
self.fill_cache()
File "/usr/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 59, in fill_cache
self.firmware_version()
File "/usr/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 89, in firmware_version
with self._bt_interface.connect(self._mac) as connection:
File "/usr/lib/python3.7/site-packages/btlewrap/base.py", line 44, in enter
self._backend.connect(self._mac)
File "/usr/lib/python3.7/site-packages/btlewrap/bluepy.py", line 32, in _func_wrapper
raise BluetoothBackendException() from last_error
btlewrap.base.BluetoothBackendException
Traceback (most recent call last):
File "/usr/lib/python3.7/site-packages/btlewrap/bluepy.py", line 26, in _func_wrapper
return func(*args, **kwargs)
File "/usr/lib/python3.7/site-packages/btlewrap/bluepy.py", line 55, in connect
self._peripheral = Peripheral(mac, iface=iface)
File "/btle.py", line 391, in init
File "/btle.py", line 439, in _connect
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral 58:2D:34:32:D4:C4, addr type: public
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "data-read.py", line 49, in
temperature = poller.parameter_value(MI_TEMPERATURE)
File "/usr/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 125, in parameter_value
self.fill_cache()
File "/usr/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 59, in fill_cache
self.firmware_version()
File "/usr/lib/python3.7/site-packages/mitemp_bt/mitemp_bt_poller.py", line 89, in firmware_version
with self._bt_interface.connect(self._mac) as connection:
File "/usr/lib/python3.7/site-packages/btlewrap/base.py", line 44, in enter
self._backend.connect(self._mac)
File "/usr/lib/python3.7/site-packages/btlewrap/bluepy.py", line 32, in _func_wrapper
raise BluetoothBackendException() from last_error
btlewrap.base.BluetoothBackendException
Error polling device bath_room:
None
Error polling device living_room:
None
Error polling device nicolas_room:
None
Any help?
Thanks!
Jorge
If the device is not found fail with a (configurable) timeout
First thing is first, so thank you for this project!
I've seen this project https://github.com/custom-components/sensor.mitemp_bt collects the data sent by the sensors instead pooling them, so the battery of those sensors is longer. It would be nice to be able to do the same with this project as well.
Thanks! See 'reverse' issue here custom-components/ble_monitor#34
Hi,
I have a doubt regarding the poller initialization:
poller = MiTempBtPoller(mac, BluepyBackend, ble_timeout=config[device].getint("timeout", 10))
Shouldn't it be?:
poller = MiTempBtPoller(mac, BluepyBackend, 600, 3, 'hci0', ble_timeout=config[device].getint("timeout", 10))
Best regards.
Hey,
Unfortunately can't read from small Xiaomi Bluetooth Temp & Hum sensors, known as LYWSD03MMC. There is the photo of the device: imgurl link
I have always this message:
Error polling device Bedroom BLE. Device might be unreachable or offline.
But for sure works great with MJ_TH_V1
If you have some idea how to read from LYWSD03MMC, I will be very grateful.
Traceback (most recent call last):
File "/usr/src/app/data-read.py", line 29, in <module>
poller = MiTempBtPoller(mac, BluepyBackend, ble_timeout=config[device].getint("timeout", 10))
File "/usr/src/app/mitemp/mitemp_bt/mitemp_bt_poller.py", line 34, in __init__
self._bt_interface = BluetoothInterface(backend, adapter)
TypeError: __init__() takes 2 positional arguments but 3 were given
A declarative, efficient, and flexible JavaScript library for building user interfaces.
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ššš
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ā¤ļø Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.