jarekj9 / mitempjj

Data gathering and visualization for Xiaomi temperature and humidity sensor. Made using docker/python/django/mysql.
49 stars 7 forks source link

Can't connect to Mi Temperature and Humidity Sensor (Qingping Temp & RH M) #11

Open iholoviy opened 2 years ago

iholoviy commented 2 years ago

Hi there, it seems that I have another firmware version on the sensor and due to it the script fails with 'expected a character, but string of length 2 found'

pi@raspberrypi:~/mitempjj $ python3 /home/pi/mitempjj/poll_sensor.py
Getting data from Mi Temperature and Humidity Sensor
Traceback (most recent call last):
  File "/home/pi/mitempjj/poll_sensor.py", line 127, in <module>
    main()
  File "/home/pi/mitempjj/poll_sensor.py", line 123, in main
    battery,temp,hum = poll(args)
  File "/home/pi/mitempjj/poll_sensor.py", line 59, in poll
    print("FW: {}".format(poller.firmware_version()))
  File "/usr/local/lib/python3.7/dist-packages/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 2 found

the firmware version on the sensor is 1.0.1_0093

jarekj9 commented 2 years ago

Perhaps it would help to change version of mitemp-bt in requirements.txt from "mitemp-bt==0.0.1" to just "mitemp-bt". Unfortunatelly I can't test as I only have 1 of these old round sensors. Please note, it will not work with new sensors, that use encryption, only with the one in the picture.