Closed jascdk closed 3 years ago
Sure, but we need some data from the device. Please follow the instructions in the FAQ on how to get the data.
Sure, but we need some data from the device. Please follow the instructions in the FAQ on how to get the data.
Cool! Just tried to follow the guide. I do not get any logs in the logging section of HA. I have it set up like in the FAQ / Readme and the "report unknown " turned on in the integration . Nothing comes through?
That might mean that the messages do not follow the structure we expect. There is a second method in the faq with Hcidump which you can try. This shows all BLE messages that are received, not only those from Xiaomi. This method might not work on Hassio, but you can try. If you have a supervised, venv or docker installation, it should work.
Furthermore, make sure the toothbrush is connected to MiHome. Close the MiHome app when trying to get the data.
@Ernst79 thanks for the quick response:) I will try setting up a standalone RPI to get the messages as you say. For information - i have opened an issue under the esphome-github repo here https://github.com/esphome/feature-requests/issues/517
I got some messages using a BLE scanner on my phone. I dont know if any of these values can be used for this integration?
All the best
Jacob / Denmark
Its easier if you can get the full messages with HCIDUMP. Especially because they don't follow the Xiaomi MiBeacon format, If I have the full messages, it's much easier to add it without errors.
@jaccdk Did you had the possibility to collect some data? I'm currently working on another toothbrush, see #319.
Just a check, when you tried it with report_unknown, did you enable debug logging as well?
@jaccdk Did you had the possibility to collect some data? I'm currently working on another toothbrush, see #319.
Just a check, when you tried it with report_unknown, did you enable debug logging as well?
Hi Ernst. Uhhh - I never came any further - did not have the time. I will try to look into it ASAP:)
Let me know if you need some help. If you install 1.9.1-beta, it's easier than before to get the data.
Set the option report_unknown
to "Xiaomi" and add logging of BLE monitor to your configuration.
ble_monitor:
report_unknown: "Xiaomi"
logger:
default: warn
logs:
custom_components.ble_monitor: info
You will find the needed info in the home assistant log. If the toothbrush doesn't follow the Xiaomi format, you can try to use
ble_monitor:
report_unknown: "Other"
This last option will collect all messages, so we than need to figure out which ones correspond to your toothbrush.
Please note, the above only works with 1.9.1-beta and above.
I want to help with this. I've the same toothbrush. This is what the "ble" program for Android shows, if it helps:
I've enabled the logs too. Under Xiaomi I can't see nothing, under Other I get a lot of info, but I don't know how can I know if it is from my device or not. Here is the log. Some of the hex strings of the raw data from the captures, appear in the log.
Thanks, I had a first quick look.
-------------------------------------------------------------------------------------------------------------------------------------------------
HCI Evt Len Sub Num Evt Peer -------MAC------- Len Len Type Val Len Type UUID Frame Product Len Type ------MAC--------- RSSI
type code evt rep type addr ctrl ID
-------------------------------------------------------------------------------------------------------------------------------------------------
04 3e 1f 02 01 00 00 a3 b6 63 45 28 70 13 02 01 04 07 02 03 18 02 18 f5 fe 07 ff a3 b6 63 45 28 70 bc
I'm not sure about the UUID etc, I'll look into what data is what later. But I didn't find the "long" message, as in your first screenshot. The ones in your log only have the data with length 02, 07 and 07. The data with the extra length 09 as in your first screenshot was not in the txt file.
Could you try to create a log while you turn your tooth brush on/off and change the speed? All message are now the same. You can recognize your device by the MAC address . (often reversed per two characters). All messages that have a3b663452870
belong to your toothbrush.
If you can't find any long messages, try again with active_scan: True
. Or just upload both attempts and I will check it for you.
I have tested with and without active_scan
enabled. Filtering by the MAC now I get this:
2021-05-03 18:05:17 INFO (Thread-20) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e1f02010000a3b66345287013020104070203180218f5fe07ffa3b663452870bc
2021-05-03 18:05:17 INFO (Thread-20) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e1602010400a3b6634528700a09094f636c65616e2058bd
2021-05-03 18:05:19 INFO (Thread-20) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e1f02010000a3b66345287013020104070203180218f5fe07ffa3b663452870b1
2021-05-03 18:05:28 INFO (Thread-20) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e1f02010000a3b66345287013020104070203180218f5fe07ffa3b663452870b8
2021-05-03 18:05:34 INFO (Thread-20) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e1f02010000a3b66345287013020104070203180218f5fe07ffa3b663452870b8
2021-05-03 18:05:43 INFO (Thread-20) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e1f02010000a3b66345287013020104070203180218f5fe07ffa3b663452870ba
2021-05-03 18:05:43 INFO (Thread-20) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e1602010400a3b6634528700a09094f636c65616e2058bc
2021-05-03 18:05:44 INFO (Thread-20) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e1f02010000a3b66345287013020104070203180218f5fe07ffa3b663452870bc
2021-05-03 18:05:44 INFO (Thread-20) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e1602010400a3b6634528700a09094f636c65616e2058bd
I can't find the long message, but I see some shorter.
Here you have the log without filtering if it helps. ble_capture2.zip
The raw data of the screen capture is what appears in the "identification" screen of the program BLE Scanner. The others are the information that the devices publishes after "connecting" with the BLE Scanner.
The shorter messages are the messages with length 09. They are apparently send in two different messages. I'll check if it contains something useful.
I had a look, but as far as I can see, it doesn't contain useful data.
-------------------------------------------------------------------------------------------------------------------------------------------------
HCI Evt Len Sub Num Evt Peer -------MAC------- Len Len Type Flag Len Type service service manufacturer Len Type ------MAC--------- RSSI
type code evt rep type addr UUID UUID UUID
-------------------------------------------------------------------------------------------------------------------------------------------------
04 3e 1f 02 01 00 00 a3 b6 63 45 28 70 13 02 01 04 07 02 03 18 02 18 f5 fe 07 ff a3 b6 63 45 28 70 bc
04 3e 1f 02 01 00 00 a3 b6 63 45 28 70 13 02 01 04 07 02 03 18 02 18 f5 fe 07 ff a3 b6 63 45 28 70 bc
-------------------------------------------------------------------------------------------------------------------------------------------------
HCI Evt Len Sub Num Evt Peer -------MAC------- Len Len Type ---device name--------- RSSI
type code evt rep type addr
-------------------------------------------------------------------------------------------------------------------------------------------------
04 3e 16 02 01 04 00 a3 b6 63 45 28 70 0a 09 09 4f 63 6c 65 61 6e 20 58 bd
The data I found in these messages are Flags, Service UUID, MAC address and the name.
Flags
02 01 04:
Length 02 bytes
Type = 0x01 represents <<Flags>>
04 = 00000100
Bit 2 is set --> “BR/EDR Not Supported.”
services UUID
07 02 03 18 02 18 f5 fe
Length = 07 bytes
Type = 0x02 represents «Incomplete List of 16-bit Service Class UUIDs»
03 18 02 18 f5 fe
1803 --> Link Loss
1802 --> Immediate Alert
fef5 --> Dialog Semiconductor GmbH
MAC address
07 ff a3 b6 63 45 28 70
Length 07 bytes
Type = 0xff represents «Manufacturer Specific Data»
a3 b6 63 45 28 70 (= MAC address)
Device name
09 09 4f 63 6c 65 61 6e 20 58 bd
Length 09 bytes
Type = 0x09 represents «Device Name»
4f 63 6c 65 61 6e 20 58
O c l e a n X
Oclean X
So, unless you can find more/different data messages, I'm afraid the toothbrush doesn't send data. Try to run it for a longer period. Possibly when you open the app, it might send useful data.
Edit Question, did you add the toothbrush to Mi Home?. Some "sensors" need to be paired with the Mi Home app or another app first before they start to send useful data (not sure if it is supported in Mi Home though, I expect it has it's own app).
It has it's own app, called Oclean. It is paired with it since more than a year ago, and I open it to sync the data from time to time. I will try to log more time to see if I can find something different.
I think the Bluetooth toothbrush uses a connection between the toothbrush (called peripheral in Bluetooth terms) and the app/phone (central) for the exchange of more detailed data. This means it isn’t sending (useful) data without setting up a connection. BLE monitor is not able to set up connections, as it is passively listening.
you can give it a try to get some logs from a longer period, but I’m a bit afraid that what we have is all we can get passively.
It has it's own app, called Oclean. It is paired with it since more than a year ago, and I open it to sync the data from time to time. I will try to log more time to see if I can find something different.
@McGiverGim any news with the toothbrush? :)
No, I wasn't able to get something useful so I abandoned some time ago ☹️
No, I wasn't able to get something useful so I abandoned some time ago ☹️
Hi:D
I managed to get the battery state with ESPHOME and an esp32 dev-board as "gateway" !:)
Use this config:
esp32_ble_tracker:
ble_client:
sensor:
platform: ble_client
ble_client_id: oclean name: "Oclean Battery" service_uuid: '180f' characteristic_uuid: '2a19' icon: 'mdi:battery' unit_of_measurement: '%'
I can't see a place where to put the characteristic_uid
in the UI. I'm not using ESPHOME. @Ernst79 can you help with this?
Ble monitor doesn’t support sending BLE messages, it can only passively listen to it. Sometimes, a sensor only broadcast with active scan enabled, which is supported. But sending BLE advertisements to ask for data isn’t possible with BLE monitor. There is an issue with that request, but I don’t have plans to look into that soon, due to my limited time at the moment.
Thanks @jascdk for your post. Found it via Google and got the battery sensor working immediately.
My code in ESPHome for a NodeMCU ESP32:
esp32_ble_tracker:
ble_client:
- mac_address: 70:28:45:68:7D:9D
id: oclean
sensor:
- platform: ble_client
ble_client_id: oclean
name: "Oclean Battery"
service_uuid: '180f'
characteristic_uuid: '2a19'
icon: 'mdi:battery'
unit_of_measurement: '%'
This is the output in the ESPHome log:
[00:26:26][D][sensor:125]: 'Oclean Battery': Sending state 100.00000 % with 0 decimals of accuracy
Finally in Home Assistant the sensor is automatically discovered and added:
No, I wasn't able to get something useful so I abandoned some time ago ☹️
Hi:D
I managed to get the battery state with ESPHOME and an esp32 dev-board as "gateway" !:)
Use this config:
esp32_ble_tracker:
ble_client:
- mac_address: FF:FF:20:00:0F:15 id: ocean
sensor:
- platform: ble_client ble_client_id: oclean name: "Oclean Battery" service_uuid: '180f' characteristic_uuid: '2a19' icon: 'mdi:battery' unit_of_measurement: '%'
How did you know the service_uuid and characteristic_uuid value?
Hi all:)
Firsts of all - just got the HA Integration up and running - what a nifty little integration big thanks to all in here for making it happen.
I just bought an OCLEAN X electric toothbrush from Xiaomi. It has BLE built in. Would it be possible to integrate it in this integration?
I will do my best to give some of the data output from it.
https://oclean.com/products/oclean-x
All The Best
Jacob / Denmark