-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sensor: MiFlora #74585
Comments
Hey there @Danielhiversen, @basnijholt, mind taking a look at this issue as it has been labeled with an integration ( miflora documentation |
This is mentioned in the breaking changes (see "Bluetooth (multiple integrations)") and due to bluepy not working with python 3.10. This will unlikely be fixed unless someone takes on the challenge of porting it to a new library that is still supported. |
There is already a issue pending with the used miflora package: basnijholt/miflora#170 |
It actually looks like the best approach would be to add an extra bleak backend entry in btlewrap, the library that miflora uses for its bluetooth interactions, |
At the moment, the only fix is to revert to 2022.6.x version of Home Assistant. Hopefully the code owners can convert this to BLEAK, or maybe someone can fork and fix bluepy. I don't have the knowledge to do this though, so I am staying on 2022.6.7 for now |
No need to fork, I would welcome any PR fixing this issue. |
Small update: for example Mi flora with bluepy uses the following handle: So now I'm trying to figure out how to convert all the needed hexa's to the related UUIDS. #%%
import asyncio
from bleak import BleakScanner, BleakClient
address = 'YOURADRESSHERE'
async def main(address):
cl = BleakClient(address)
async with cl as client:
services = await client.get_services()
chars = services.characteristics
for i in services.characteristics:
char = chars[i]
descs = [f'{i.description=} {i.handle=} {i.uuid=}' for i in char.descriptors]
descsvals = [await client.read_gatt_descriptor(i.handle) for i in char.descriptors] if 'read' in char.properties else 'nopenope'
gattchar = await client.read_gatt_char(i) if 'read' in char.properties else 'nope'
print(f'''---------------------
{gattchar=}
{char.handle=}
{char.description=}
{descs=}
{descsvals=}
{char.handle=}
{char.properties=}
{char.service_handle=}
{char.service_uuid=}
{char.uuid=}
--------------------''')
await main(address) I did find some translation in the bluepy library (link to related code found) but with that I was still not able to get this same translation: val = 0x03
val = "%04X" % val
val = val.replace("-", "")
s = ("0" * (8 - len(val))) + val + "00001000800000805F9B34FB"
"-".join([s[0:8], s[8:12], s[12:16], s[16:20], s[20:32]]) which makes from |
I have reverted to 2022.6 some days ago and hassio still doesn't update my sensors :/ weird... |
Before someone decides to go all out on this one, there is actually effort being put into bringing a generic The first iteration |
@FluffyGeraffe Hopefully the new work will be successful and help solve it. I think the developer of the BTL wrapper is also working to move over to bleak |
Thanks @austwhite for confirming, that it should work after reverting. Maybe I'll readd my 3 sensors again or I'll just wait for the update. Lucky for you that it still works with 10 sensors. That would have been annoying in my case 😁 |
This comment was marked as duplicate.
This comment was marked as duplicate.
Made an add-on as a work-around until bleak is supported in btlewrap. Check it out here, https://github.com/selleronom/xiaomi-mi-flora |
Bleak is async, it doesn't look like btlewrap is. So we should just probably use bleak directly instead of waiting for btlewrap. I've started writing a bleak based client for this device. But I need some more batteries before I can turn it on and test it. With the new Bluetooth framework we should actually just be able to listen to the data in the BLE broadcasts and only need to poll for the battery. So might reduce battery consumption! |
I can actually confirm this approach will save the miflora battery as this was my reason for me to start using the hacs passive ble monitor for listening only to the miflora and used the miflora integration only to poll the battery status once a day…. |
I know the maintainer of btlewrap was looking at Bleak at one point. |
We are working on a new approach to Bluetooth in Home Assistant, not a fix to this exactly. But by implementing the new best practices we will fix it as a side effect - because the broken dependency (bluepy) will be gone. |
Any idea when this might be implemented? As early as 2022.8? |
No promises, I am rammed and I've been given at ETA of Friday for the APIs to land in HA core, and that's if they clear review. So there isn't going to be much time to get my stuff written and landed. Also because the Mi Flora actually uses the same framing protocol as a bunch of other devices it's been requested I don't do something just for this device. If I do get something out it'll likely be just the values that are advertised (ie no battery support), then I'll come back to battery support in 09. Otherwise everything would be in 09. |
I use home assistant with synology ds918+ nas, inside Virtual Machine Manager, Logger: homeassistant.util.package Unable to install package bluepy>=1.3.0: error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [8 lines of output] /usr/local/lib/python3.10/site-packages/setuptools/dist.py:772: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead warnings.warn( running bdist_wheel running build running build_py Working dir is /tmp/pip-install-ume9b6ym/bluepy_feb51896dc3c4ad2b8f2ab1835113634 execute make -C ./bluepy clean error: [Errno 2] No such file or directory: 'make' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for bluepy error: subprocess-exited-with-error × Running setup.py install for bluepy did not run successfully. │ exit code: 1 ╰─> [10 lines of output] /usr/local/lib/python3.10/site-packages/setuptools/dist.py:772: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead warnings.warn( running install /usr/local/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build running build_py Working dir is /tmp/pip-install-ume9b6ym/bluepy_feb51896dc3c4ad2b8f2ab1835113634 execute make -C ./bluepy clean error: [Errno 2] No such file or directory: 'make' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> bluepy note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure. Logger: aiohttp.server Error handling request Logger: aiohttp.server Error handling request |
@warlordattack This issue is particualrly related to MiFlora devices, but the fix on this would likely fix your issue too. |
thank you, i have core-2022.7.5, where can i find 2022.6.x ? i installed https://github.com/home-assistant/operating-system/releases/download/8.2/haos_ova-8.2.vmdk.zip |
@warlordattack you need CLI access, either by SSH or the Terminal addon, then the command is ha core update version=2022.6.7 |
so it will downgrade the system ? |
@warlordattack |
ok thank you for advice |
Ah my bad it's -version=2022.6.7 with a hyphen in front. |
Okay, I understand. Thanks for the answer! |
Hey guys - as i said above I wanted to work on getting MiFlora supported using bleak and the new Bluetooth infrastructure thats coming in the 08 release. The initial plan was to make a new miflora library that was optimised for homeassistant, bleak and asnycio and then contribute to the existing miflora integration. But It turns out the HHCCJY01 is supported by another integration that was planned based on that new infratructure. It covers a bunch of devices using Xiaomi / MiBeacon bluetooth advertisements (using the parser from the ble_monitor custom component). Because it covers more devices i collaborated to get that integration landed. It has made it onto dev in time for the next beta and so should be in the August release. It's working well with my own MiFlora devices: As its based on the new bluetooth component your MiFlora should appear as "Discoveries" when you upgrade. No more faffing around with CLI tools to find MAC addresses. Unfortunately as its a different integration there isn't an automated migration path. As its based on bluetooth advertisements its "push" based - you should get new sensor data as soon as the device knows it, rather than having the lag of polling. But without increasing battery use. In fact, your battery burn rate will decrease. Right now there is no battery sensor. I do plan to add support for polling the battery for MiFlora to that integration too, but that won't make it into the August release based on the time I have left and the release date of the first beta. But the core sensors are present and working. I'm hoping to add "identify" support too - you'll be able to use a button or service call to make the light on the miflora flash, so if you mix them up you can easily find which is which. |
@Jc2k |
Right now there is no battery sensor. I do plan to add support for polling the battery for MiFlora to that integration too, but that won't make it into the August release based on the time I have left and the release date of the first beta. |
@Jc2k Thanks for your work on getting MiFlora sensors to work again! 🙏 Is there an issue we can follow for the battery polling support? I'm still on 2022.6 and would wait with updating until sensors are fully supported again. |
No theres no issue, though i'll probably post here when i implement it. Hoping it will be 2022.9, but it was a real challenge to get the main sensors supported in 2022.8 with life commitments etc and likely to be lots of triage over the next 2 weeks with the new xiaomi_ble integration (e.g. already had a lot of trouble with the LYWSD03MMC and that was just with beta testers) and new bluetooth support in homekit_controller - expecting both to suck up a lot of what little time i have. |
I see, no worries - posting here would also help! 😊 |
Thanks for that! One thing though. I've written down which MAC-Address is which plant. Now I don't see MAC-Addresses anymore. Is there a way to get to see those? Every device is just called "Flower Care" |
That's annoying! One of mine gets named after is MAC address and another is just "Flower Care". Will try to do something about that, and I also plan to add a "flash the LED" button to each one so new users will never see the MAC address and never need to. |
Yeah, one out of my 10 was named after its MAC Address as well, but thats only one :) |
I've been testing new Xiaomi BLE integration for last two weeks. I have to say it works dramatically worse that Passive BLE Monitor. Xiaomi BLE is unavailable most of the time, not reporting the values for days, whereas Passive BLE works reliably and reports values every 15-30 minutes. |
On my end it is also not reliable but I don't think it is the Xiaomi ble integration for the flora sensors |
@denysdovhan and @ioannispelelis If you are still having an issue after that, please look to log a new issue as this issue is closed. |
I've been using the new Xiaomi BLE integration with 3 Flora devices using
the built-in bluetooth adapter from a Pi 4 without any issues so far.
These 3 Flora devices are quite far away from the Raspberry itself,
considering the propagation of BT (2 x backyard, 1 x front yard) and the
data is still received without any problems.
Regards / Saludos / Salutacions,
Tedi Roca
https://tedi.es
…On Thu, 11 Aug 2022 at 15:55, austwhite ***@***.***> wrote:
@denysdovhan <https://github.com/denysdovhan> and @ioannispelelis
<https://github.com/ioannispelelis>
Check the bluetooth adapters you are using compared to the list on the
Bluetooth integration.
Also try removing the Flowercare products and readding them. Mine went
unavailable once, but the remove and readd fixed it and they have been rock
solid ever since. Also make sure your config.yaml has all the old MiFlora
stuff removed.
If you are still having an issue after that, please look to log a new
issue as this issue is closed.
—
Reply to this email directly, view it on GitHub
<#74585 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAOPRCFFLZGDZ2VL5IB57KTVYUA5PANCNFSM524QMEZQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
My experience, using a HA OS VM with USB passthrough bluetooth dongle, was that the passive BLE AND the new flora integration did not cooperate nicely running both at the same time. After removing passive ble (not using it for other purposes) the new flora integration worked as reliable as passive ble before. |
@stephan890 That's fairly typical of Bluetooth dongles. The like to run with just one machine and do not share well. |
From my side - Xiaomi BLE seems working fine on RPI 4B built-in bluetooth module (4 mi flora devices). Updates are coming every several seconds. The issue I've noticed is that it 'blocks' other bluetooth integrations - i.e. BLE tracker stopped to work (it can update status only during HA restart but not when everything's running). Still big thanks for bringing mi flora back to life and hope that integrations conflicts can be solved in future :) |
Cheers @banan77. If you mean the ble tracker integration in HA core (i.e. this one -> https://www.home-assistant.io/integrations/bluetooth_le_tracker/) - you should definitely raise a new ticket for that. Both integrations are written to work with the new bluetooth integration (https://www.home-assistant.io/integrations/bluetooth/) so shouldn't conflict. |
The problem
Platform error sensor.miflora - Requirements for miflora not found: ['bluepy==1.3.0'].
What version of Home Assistant Core has the issue?
2022.7.0
What was the last working version of Home Assistant Core?
2022.6. latest
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Mi Flora
Link to integration documentation on our website
https://www.home-assistant.io/integrations/miflora/
Diagnostics information
No response
Example YAML snippet
Anything in the logs that might be useful for us?
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: