basnijholt / miflora

☘️🌑🌼πŸ₯€πŸ‘ Mi Flora Plant sensor Python package
MIT License
366 stars 98 forks source link

Support for battery, other characteristics #1

Closed lwis closed 7 years ago

lwis commented 7 years ago

I read your post on reverse engineering the BLE API, and noticed that the app is able to query the battery level of the sensor - would it be possible to query this, and potentially other things? Such as syncing the history of the sensor?

ghost commented 7 years ago

Unfortunately I don't have any information how to read the battery level and the history. The standard battery attribute doesn't seem to be supported (if I checked this correctly)

julcollas commented 7 years ago

Hi, I don't know for the history but for battery level and firmware version seems to be in 0x38. (cf https://github.com/LeonGaultier/fhem-XiaomiFlowerMonitor/blob/devel/74_XiaomiFlowerSens.pm#L297)

battery = read_ble(self._mac, '0x038', retries=self.retries)[0]
return battery

For version 2.6.6 you need to write in 0x33 before getting information (cf: https://github.com/LeonGaultier/fhem-XiaomiFlowerMonitor/blob/devel/74_XiaomiFlowerSens.pm#L278)

ghost commented 7 years ago

@julcollas : Thanks, I will integrate this.

ghost commented 7 years ago

This has been implemented now. Can you do a test with the latest version?

julcollas commented 7 years ago

Seems ok for me . Thanks !