rubinho101/MMM-01ZM

... Error with parseBLE01ZM.py

Closed this issue · 4 comments

Hi, when i run python 3 with parseBLE01ZM.py this comes up.. Can you help me?

[2020-12-12 14:34:59 +0100] [4118] [ERROR] Exception occurred while handling uri: 'http://localhost:8000/?mac=A4:C1:38:F1:9D:5B'
Traceback (most recent call last):
File "/home/pi/.local/lib/python3.7/site-packages/sanic/app.py", line 939, in handle_request
response = await response
File "/home/pi/MagicMirror/modules/MMM-01ZM/mitemp/parseBLE01ZM.py", line 26, in poll
print("FW: {}".format(poller.firmware_version()))
File "/home/pi/MagicMirror/modules/MMM-01ZM/mitemp/mitemp_bt/mitemp_bt_poller.py", line 105, in firmware_version
self.battery = int(ord(res_battery))
TypeError: ord() expected a character, but string of length 15 found
[2020-12-12 14:34:59 +0100] - (sanic.access)[INFO][127.0.0.1:35490]: GET http://localhost:8000/?mac=A4:C1:38:F1:9D:5B 500 735

PS: Does a number for the sensor have to be added after the mac address?

Hi, which sensor are you using - the LYWSDCGQ 01ZM? TypeError: ord() expected a character, but string of length 15 found seems to be the issue. Somehow your sensor does not send a string of lengths one (the ord() translates a single character to a number)
Since the state of charge of the battery is not required for now, you could try to change /mitemp/mitemp_bt/mitemp_bt_poller.py line 105 to self.battery = str(res_battery). In addition, after changing line 105, could you run parseBLE01ZM.py in your IDE, invoke the sensor in the browser directly (http://localhost:8000/?mac=A4:C1:38:F1:9D:5B) and tell me what the IDE returns for *Battery: *

Regarding your second question: No you dont have to put a room number after the mac address. The node_helper.js uses a loop to set the room number. Hence, the first MAC address will be Room 1 and so on...

Hey,

for me it doesn't work as well.
Same battery issue, after changing to str(res_battery) i get the following:

[2023-07-01 18:19:00 +0200] [27643] [ERROR] Exception occurred while handling uri: 'http://192.168.188.41:8000/?mac=A4:C1:38:37:E8:14'
Traceback (most recent call last):
  File "handle_request", line 97, in handle_request
    from sanic_ext.extensions.base import Extension  # type: ignore
  File "/home/pi/MagicMirror/modules/MMM-01ZM/mitemp/parseBLE01ZM.py", line 28, in poll
    print("Battery: {}".format(poller.parameter_value(MI_BATTERY)))
  File "/home/pi/MagicMirror/modules/MMM-01ZM/mitemp/mitemp_bt/mitemp_bt_poller.py", line 134, in parameter_value
    raise BluetoothBackendException("Could not read data from Mi Temp sensor %s" % self._mac)
btlewrap.base.BluetoothBackendException: Could not read data from Mi Temp sensor A4:C1:38:37:E8:14

Btw. I can read my sensor using MiTemperature2:

pi@smartmirror:~/MiTemperature2 $ ./start.sh 
---------------------------------------------
MiTemperature2 / ATC Thermometer version 5.0
---------------------------------------------


Please read README.md in this folder. Latest version is available at https://github.com/JsBergbau/MiTemperature2#readme
This file explains very detailed about the usage and covers everything you need to know as user.

Trying to connect to A4:C1:38:37:E8:14
Temperature: 26.08
Humidity: 45
Battery voltage: 3.068 V
Battery level: 97