Passive BLE Monitor integration (Xiaomi Mijia BLE MiBeacon monitor)

Yes you are right )

1 Like

@Magalex does this work if you do not have a gateway? The App seems to insist on it.

Yes, a gateway is not needed. Perhaps there are exceptions (I only have LYWSDCGQ, MiFlora, and LYWSD03MMC, and I do not have gateways). What kind of sensor are we talking about?

I’ve got 5 LYWSDCGQ. Actually, I tried it and they connected (without connecting to the APP first). after I pulled the battery and reinserted it.

Range seems significantly worse that the polling version (on a different Pi).

Could you add a last updated timestamp attribute?

As an aside, would it be possible to run this standalone and either provide HA with an API to access the sensors or send the data via MQTT?

Range seems significantly worse that the polling version

Many have the opposite observation. Range should be greater.

Could you add a last updated timestamp attribute?

Any sensor entity already has it. You can try this (Developer Tools - Templates, replaсe mi_t_1 with your sensor actual name:

{{states.sensor.mi_t_1.last_updated}}

As an aside, would it be possible to run this standalone and either provide HA with an API to access the sensors or send the data via MQTT?

In the case of LYWSDCGQ - this sensor is supported in ESPHome (also passive reception).

There is also a mention in our FAQ about the remote_homeassistant component.

There is an issue for a standalone solution, but I have not yet had time to really think it over.

1 Like

It may be the heatsink case on the Pi4 :frowning_face:. I’m going to get an external BT dongle and try that.

Every day is a learning day - thanks that actually solves some other problems of mine :grinning:.

Yes, tried that without success.

Missed that - again more learning today - thanks.

Excellent component - should replace the standard one IMHO.

1 Like

Yes, the metal case is a big problem for the builtin bt-module (and wifi).
I think this is also worth to mention in the FAQ.

1 Like

Installing the new version of the component in order to get data from a LYWSD03MMC sensor, restarting home assistant i get this error:

Exception in thread Thread-23:
Traceback (most recent call last):
File “/usr/local/lib/python3.7/threading.py”, line 926, in _bootstrap_inner
self.run()
File “/config/custom_components/mitemp_bt/sensor.py”, line 113, in run
return None
File “/usr/local/lib/python3.7/site-packages/aioblescan/aioblescan.py”, line 1280, in create_bt_socket
sock = socket.socket(family=socket.AF_BLUETOOTH,
AttributeError: module ‘socket’ has no attribute ‘AF_BLUETOOTH’

what could it be?
Thanks for suggestions

This is the first time I encounter such error… Hmmm…
Found this - https://github.com/docker-library/python/issues/444

What is you setup?

Hi.

I am getting this error while trying to compile code on ESPHOME (Home Assistant)…

INFO Reading configuration /config/esphome/xiaomi_mijia.yaml...
ERROR Error while reading config: Invalid YAML syntax. Please see YAML syntax reference or use an online YAML syntax validator:

mapping values are not allowed here
  in "/config/esphome/xiaomi_mijia.yaml", line 37, column 36:
        encryptors: 'A4:C1:38:2F:86:6C': '217C568CF5D22808DA20181502D84C1B'
                                       ^

Thanks,
JH

Hello! mac:key pair must be a dictionary, just place it at the next line, how stated in the docs (will be updated with new release soon):

Sorry, it is my fault, the documentation in release 0.6.1 is misleading

Copying and pasting an example from the documentation is useless, since you do not have a sensor with such a mac address, and the key will not work. Please read the documentation attentivly.

Yes it is, but I never use the app.

I’m using this: https://www.aliexpress.com/item/32952692648.html?spm=a2g0s.9042311.0.0.27424c4dTLsWC0

lsusb

Bus 004 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

dmesg | grep -i blue

[    8.971689] Bluetooth: Core ver 2.22
[    8.971715] Bluetooth: HCI device and connection manager initialized
[    8.971720] Bluetooth: HCI socket layer initialized
[    8.971723] Bluetooth: L2CAP socket layer initialized
[    8.971726] Bluetooth: SCO socket layer initialized
[   10.208417] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[   10.208419] Bluetooth: BNEP filters: protocol multicast
[   10.208425] Bluetooth: BNEP socket layer initialized
[   19.489154] Bluetooth: RFCOMM TTY layer initialized
[   19.489163] Bluetooth: RFCOMM socket layer initialized
[   19.489172] Bluetooth: RFCOMM ver 1.11
[60791.482886] Bluetooth: hci0: hardware error 0x41
[62608.715302] Bluetooth: hci0: hardware error 0x41
[62854.825431] Bluetooth: hci0: hardware error 0x41
[64566.660536] Bluetooth: hci0: hardware error 0x41
[66222.037802] Bluetooth: hci0: hardware error 0x41
[70948.962123] Bluetooth: hci0: hardware error 0x41
[78341.333330] Bluetooth: hci0: hardware error 0x41
[80820.086099] Bluetooth: hci0: hardware error 0x41
[82278.376128] Bluetooth: hci0: hardware error 0x41
[94768.337951] Bluetooth: hci0: hardware error 0x41
[125935.015914] Bluetooth: hci0: hardware error 0x41
[127871.261646] Bluetooth: hci0: command 0x200e tx timeout
[127876.285911] Bluetooth: hci0: command 0x0419 tx timeout
[127881.310222] Bluetooth: hci0: command 0x0419 tx timeout
[127886.110559] Bluetooth: hci0: command 0x200e tx timeout
[127888.126681] Bluetooth: hci0: command 0x0419 tx timeout
[127891.326752] Bluetooth: hci0: command 0x0419 tx timeout
[156792.824739] Bluetooth: hci0: hardware error 0x41
[158393.172827] Bluetooth: hci0: hardware error 0x41
[160200.010124] Bluetooth: hci0: hardware error 0x41
[179706.330872] Bluetooth: hci0: hardware error 0x41
[183615.491661] Bluetooth: hci0: hardware error 0x41

Hmm, that hardware error and timeout doesn’t look good. I’ll reboot the system…

Ok, now I get this…

[    7.281588] Bluetooth: Core ver 2.22
[    7.281613] Bluetooth: HCI device and connection manager initialized
[    7.281619] Bluetooth: HCI socket layer initialized
[    7.281623] Bluetooth: L2CAP socket layer initialized
[    7.281628] Bluetooth: SCO socket layer initialized
[    8.262394] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    8.262396] Bluetooth: BNEP filters: protocol multicast
[    8.262405] Bluetooth: BNEP socket layer initialized
[   17.528074] Bluetooth: RFCOMM TTY layer initialized
[   17.528088] Bluetooth: RFCOMM socket layer initialized
[   17.528109] Bluetooth: RFCOMM ver 1.11

and still no devices/sensors showing up in HA.

I’m not sure how exactly to check the syslog, sorry.

If I perform a sudo hcitool lescan sometimes it works, but then I get Input/output error, so I don’t know what’s going on with this.

I think I’ll just give up on this as it seems to be breaking a lot of things with my setup. I have a spare esp32 laying around, so I might just use that to get the sensor info I need.

I appreciate you time with this. In my case, it just doesn’t seem to work. :sob:

It seems like kernel/hardware issue - https://bugzilla.kernel.org/show_bug.cgi?id=60824.
I’m sorry about this.

All good. Not your fault.

would you mind sharing your esphome config/code to get this working in esphome?

@aidbish I’m not sure what Jose is trying to do (his post contains the words ESPHome and HomeAssistant), but this component has nothing to do with ESPHome… This component is designed to be installed in the Home Assistant.

i wonder if he has managed to incorporate it as a custom code in ESPHOME, i will await his response
Sorry for hijacking thread, but great work in getting the LYWSD03MMC working

1 Like

Hi @Magalex.

I am trying to use mitemp_bt with ESPHOME + HOME ASSISTANT using a NODEMCU board as BLE component.

Thanks,
Jose.

This is NOT an esphome component!