mitemp icon indicating copy to clipboard operation
mitemp copied to clipboard

Unsupported firmware ?

Open geensr opened this issue 2 years ago • 5 comments

I am using this module on a raspberry PI running the standard home-assistent setup. Currrent versions are core-2021.11.5, supervisor-2021.10.8 and Home Assistant OS 6.6.

The hardware is recently bought from https://www.aliexpress.com/item/1005003430486580.html and works fine in the MI app on Android.

From the Debug logs I get following result (not clear why there is only one read action in the log, according to the code the line where the battery info is read should also be logged).

2021-12-08 16:19:08 DEBUG (SyncWorker_6) [mitemp_bt.mitemp_bt_poller] Filling cache with new sensor data. 2021-12-08 16:19:11 DEBUG (SyncWorker_6) [mitemp_bt.mitemp_bt_poller] Received result for handle 36: b'Time\x00' 2021-12-08 16:19:12 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.bathroom_upstairs_temperature fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 468, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 658, in async_device_update raise exc File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run result = self.fn(*self.args, **self.kwargs) File "/usr/src/homeassistant/homeassistant/components/mitemp_bt/sensor.py", line 147, in update data = self.poller.parameter_value(self.entity_description.key) File "/usr/local/lib/python3.9/site-packages/mitemp_bt/mitemp_bt_poller.py", line 126, in parameter_value self.fill_cache() File "/usr/local/lib/python3.9/site-packages/mitemp_bt/mitemp_bt_poller.py", line 59, in fill_cache self.firmware_version() File "/usr/local/lib/python3.9/site-packages/mitemp_bt/mitemp_bt_poller.py", line 106, in firmware_version self.battery = int(ord(res_battery)) TypeError: ord() expected a character, but string of length 15 found 2021-12-08 16:19:12 DEBUG (SyncWorker_5) [homeassistant.components.mitemp_bt.sensor] Polling data for Bathroom upstairs Humidity 2021-12-08 16:19:12 DEBUG (SyncWorker_5) [mitemp_bt.mitemp_bt_poller] Filling cache with new sensor data. 2021-12-08 16:19:12 WARNING (SyncWorker_5) [homeassistant.components.mitemp_bt.sensor] Polling error Could not read data from Mi Temp sensor A4:C1:38:8D:C1:57 2021-12-08 16:19:38 DEBUG (SyncWorker_3) [homeassistant.components.mitemp_bt.sensor] Polling data for Bathroom upstairs Temperature 2021-12-08 16:19:38 DEBUG (SyncWorker_3) [mitemp_bt.mitemp_bt_poller] Using cache (0:00:26.449007 < 0:05:00) 2021-12-08 16:19:38 WARNING (SyncWorker_3) [homeassistant.components.mitemp_bt.sensor] Polling error Could not read data from Mi Temp sensor A4:C1:38:8D:C1:57

and so on.

The error is not repeated in the log but no data is ever received, also not when the cache timeout expires.

If there is anything I can do to help debug this please let me know.

geensr avatar Dec 08 '21 15:12 geensr

Unfortunately I don't have this device any more, so it's very difficult for me to provide further support. I'd appreciate if someone still having the device would step-in and help resolve this.

ratcashdev avatar Dec 08 '21 17:12 ratcashdev

I just got 2 of these devices and same problem. I suspect they indeed changed the firmware or something. I will look into it in the next couple of weeks and try to fix the library, unfortunately it's a bit complex as I assume the Bluetooth libraries used wouldn't work on a Mac and I'll need a real Linux machine with a BLE interface.

How does your sensor identify itself? Mine identifies as a LYWSD03MMC which is different from what the Home Assistant docs suggest. This may be a completely different protocol. Tasmota docs suggest that these use an encrypted protocol so it would make sense that this no longer works.

Rjevski avatar Dec 13 '21 11:12 Rjevski

I already found out about this other project https://esphome.io/components/sensor/xiaomi_ble.html. Maybe some kind of porting of the esphome solution (which supports esp32 as platform) can be ported to generic Bluetooth that works on Raspberry PI directly.

geensr avatar Dec 13 '21 12:12 geensr

Just FYI, I managed to get these to work with the https://github.com/custom-components/ble_monitor custom component and the https://pvvx.github.io/ATC_MiThermometer/TelinkMiFlasher.html custom firmware - after flashing make sure to set advertisement type to "Mi".

Rjevski avatar Dec 13 '21 13:12 Rjevski

Thank you @Rjevski

I reflashed with https://github.com/pvvx/ATC_MiThermometer and iindeed used the ble_monitor custom component to get this working flawlessly (with additional benefits from the custom firmware too).

In my opinion that is the preferred solution and could be documented like that as a solution to this issue at hand.

geensr avatar Dec 15 '21 07:12 geensr