Yes, the configuration looks correct. The only thing is that the key must be 32 characters long (both keys length must be the same).
Yes, i know that. keys are corrent. I just hide the entire keys.
Just in case, I want to note that most of the options are not really needed, since the specified values are the default values.
Your configuration might look like this:
- platform: mitemp_bt
encryptors:
'A4:C1:38:1D:16:41': '0d1bc96a6-------dd43d4319a452b8'
'A4:C1:38:0E:88:50': '96aa0e1f6---------692'
Thanks, great component. Keep up good work!
Oh, the man himself - @Magalex. I am humbled and truly appreciate your wonderful development as well as taking time out to help me.
Your tips are very useful. I hope to get things to work and report back soon.
Stay safe during these trying times!
@Magalex Dear Aleksey,
In one statement - ALL IS WELL, my dear friend!
Very glad to report that your instructions, clear and complete as they were, did result in both sensors getting registered in HA and working fine (after the usual struggle - total 3 hours; some tears, lots of smiles).
For the benefit of others (and to serve as a reminder to my own-self when I acquire more sensors after this COVID nonsense is over), here are the steps as I followed them…
Hardware:
HA updated and current. Running on Rpi3 (I know, I know - will soon move to a SSD).
2 x LYWSD03MMC sensors.
Steps Taken:
- Acquire the mac address of the LYs. Easily done via ssh to HA.
$ ha help
➜ ~ bluetoothctl
Agent registered
[CHG] Controller B8:27:EB:7E:50:F2 Pairable: yes
[bluetooth]# scan on
Discovery started
[CHG] Controller B8:27:EB:7E:50:F2 Discovering: yes
[NEW] Device A4:XX:XX:XX:XX:67 LYWSD03MMC
[NEW] Device A4:XX:XX:XX:XX:4E LYWSD03MMC
[bluetooth]# scan off
Discovery stopped
-
Copied and pasted this (to copy/paste and for added functionality, used MS Visual Studio terminal) into a blank text file and named the sensors LY1 and LY2 to avoid confusion later.
Logged off ssh.
This info may be gathered by many ways; and various other BT apps. -
Opend the Stream app on my iPhone.
Important step - In the app’s settings, choose HTTPS sniffing otherwise the whole procedure will go a waste (I learnt it the hard way). To complete this, the usual VPN trust procedure in Settings>General>About>Profiles needs installation. Make sure this profile is verified and ticked green.
Now, ensure that MiHome app is logged-in (ensure it is logged-out of other devices and region chosen is mainland China - I faced some grief on account of multiple log-in on other devices) and that the LYs are not added. Remove (delete) if needed. This can be done multiple times without any issues. Force close the app and restart it. -
On Stream, hit ‘Sniff now’ and immediately move to the MiHome app and commence the pairing procedure - don’t worry if auto discovery selects the LY. Complete the pairing and get the T and RH data from the LY. I paired only one to start with - the LY1.
‘Stop sniffing’ on Stream. This took about 65 seconds in my case. Now, goto the sniff history, Edit, Select all and ‘Export HAR’. I did this export to my NAS.
Charles Proxy app (30 day trial) was used on a mac to open the said HAR file. Use the find feature and findbind_key
It will be 32 characters long.
-
Rinse and repeat for LY2
-
From here on, things get easier! I had the LY1 and LY2 data ready in VS but not yet pasted in the Configuration.yaml
Time for an important Start/Stop procedure (I did struggle here a bit).
a) Stopped HA from here.
b) For additional measure, powered off and restarted the pi.
c) Logged-into HA and appended the config.yaml file as shown above.
d) Restarted HA.
- Waited patiently for about 15 minutes.
- Voila!! 4 new entities magically appeared into the Entities tab! Renamed them - will give a more meaningful name once I have tried them for a few days.
Well…that is all there is to it!
My best wishes and salute to Aleksey and all others who have contributed to this project and indirectly, to my…happiness - life is nothing but a pursuit of it, is it not
People, stay safe and stay happy!
Thank you for your kind words and for such a detailed step-by-step instruction! I’ll leave a link to it in our FAQ.
@Magalex, thanks for providing us with such a useful plugin. Had to recompile Python 3.8.2 with Bluetooth Sockets though, but after that it worked.
However, as I have LYWSDCGQ devices scattered all over the house, and remote_ha probably isn’t the best option (I’ve got Raspberry Pi Zero Ws around the house), I was wondering what it would take to turn https://github.com/algirdasc/xiaomi-ble-mqtt into the same passive-mode approach ? I’m using it today but it’s doing the active-mode-approach.
I think it will be easier to write own daemon (since periodic launch through cron is not suitable for passive mode - the code should be executed all the time in the background). To do this, I need to figure out how to correctly implement it in python, and figure out how to correctly publish data to MQTT.
You are not the first who asks for this, and there is a corresponding issue in our GitHub repository. The implementation of the component as a standalone is in the plans, but I still can’t allocate time for this…
I followed the steps but I cannot find the bind_key in the HAR file. I also add (until it reads temperature) and remove many times. Can you talk more details about this step?
Usually happens if HTTPS is not enabled. Please share more details.
Fully agree in the daemon approach. https://github.com/ThomDietrich/miflora-mqtt-daemon does something indeed similar.
Let me know if there is anything I can do to help/test - even though my python skills are limited at this time.
I figured out how to get bind_key and got temperature reading in Home Assistant. Thank you so much about your step-by-step instruction!
Hello, thanks for the great procedure !
Unfortunately I don’t find any bind_key when I look into the .har file.
I use stream on my Ipad with https sniffing.
Should I import the certificate from the Ipad to my win10 PC (running Charles app).
thanks a lot!!
No, a certificate should be trusted only where you sniff traffic, that is, on the iPad. This does not need to be done on a PC.
It can be frustrating…(took me a few hours to nail it). If HTTPS is there, so is the bind key…assuming the MiHope pairing went well.
I suggest you try again. Get a few minutes worth of HAR file and export them ALL…there are more than plenty there. Wish I could find a ‘select all’ option.
Ok thanks for your extremely fast answer !
Ok that’s what I did.
Thanks also for you quick answer.
Ok I will try again. (I tried 4-5 times already…)
Yes the pairing went well on the Mi home.
Any suggestion for the HAR viewer to use ? Is there a better alternative than Charles ?
@Magalex Further update…
All working well. I have read on numerous forums that the RPI3 has a lousy BT adapter - well, I beg to differ.
I live in a split level house of conrete construction.
LY2 is ca 8 meters away; same level but behind 2 brick walls.
LY1 is ca 10m away on the lower level (1 conrete slab) plus 2 brick walls.
I have yet to see a missed signal or ‘Unvailable’ on HA (that only happens after HA restart until the first polling interval).
The passive component is a very clever idea and in hindsight, the frustration of the design change on account of the LY, in my opinion, has actually led to a better and more ‘green’ solution.
God bless you, droog!
PS: Ordered 4 more LYs.
I think that the problems with bluetooth on raspberry pi in most cases are connected with poor power supply (in terms of the power ability and its “purity”) and not very good design in terms of electromagnetic compatibility (adding devices like SSDs greatly spoils the picture). So much depends on the individual characteristics of each installation. Your result pleases, yes.