Skip to content
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

Mixing ble_client with ble_gateway #11

Open
BrianAker opened this issue Jun 30, 2022 · 12 comments
Open

Mixing ble_client with ble_gateway #11

BrianAker opened this issue Jun 30, 2022 · 12 comments

Comments

@BrianAker
Copy link

Hi!

Is there a way to combine ble_client with ble_gateway?

I have miflora sensors which are being passively read via ble_gateway, I am forwarding all of their BLE data processing to Home Assistant. This is working quite well.

What is missing? The battery information. For miflora devices you need to do a read of the battery data; the firmware did at one point broadcast this information but because of the battery drain, later firmware versions for miflora plant sensors removed this feature.

Your ble_client code I think would be an awesome solution to this since you can specify intervals and you are not limited to the number of client limitations that the builtin esphome ble stack has.

So far, I haven't been able to figure out how to make it work. Do you have an example?

An optimal solution would be for the client and gateway code to use the same device list, or better, have the ble_client only make requests of devices it has seen.

Do you have anything you can share about using ble_client with ble_gateway?

Thanks!

FWIW, I have 3 esp32 tracking ~48 miflora sensors.

@myhomeiot
Copy link
Owner

You can do it like in this example, ble_client will read battery information and sends it to Passive BLE Monitor as BLE packet like earlier firmware's.

@myhomeiot
Copy link
Owner

@BrianAker Did the example helps you?

@myhomeiot myhomeiot reopened this Jul 3, 2022
@BrianAker
Copy link
Author

BrianAker commented Jul 4, 2022 via email

@myhomeiot
Copy link
Owner

OPEN_EVT failed, status (133), app_id (1) means that it's can't connect to MiFlora, sometimes it's happens but if it's can't connect at all probably the distance too far. BT connection requires lower distance than BLE, try to move this MiFlora closer to ESP.

set_devices: Devices lengths (4) must be a multiple of 12 check binary_sensor.ble_gateway devices attribute in HA, it's contains MACs which should be set at ESP and size of this attribute must be a multiple of 12 because each MAC address in hex = 12 chars.

@BrianAker
Copy link
Author

BrianAker commented Jul 5, 2022 via email

@myhomeiot
Copy link
Owner

Try to disable discovery and specify few required MACs in ESP or Home Assistant.
I use both ble_gateway and myhomeiot_ble_client simultaneously and doesn't see problems. Sometimes I seen OPEN_EVT failed, status (133) but after few tryes it's recovers.

@BrianAker
Copy link
Author

BrianAker commented Jul 9, 2022 via email

@myhomeiot
Copy link
Owner

esp_ble_gap_stop_scanning calling only at esp32_ble_tracker, MyHomeIOT_BLEClient like other BLE components registered using esp32_ble_tracker.register_client (in our case it's MyHomeIOT_BLEHost) and just called from ESP32BLETracker.

Read my reply about my observations of MiFlora battery level.

@BrianAker
Copy link
Author

BrianAker commented Jul 9, 2022 via email

@myhomeiot
Copy link
Owner

MyHomeIOT_BLEHost + MyHomeIOT_BLEClient = regular BLEClient, so you can compare logic of MyHomeIOT_BLEClient with it.
MyHomeIOT_BLEClient esp_ble_gattc_open and BLEClient esp_ble_gattc_open

@BrianAker
Copy link
Author

BrianAker commented Oct 11, 2022 via email

@myhomeiot
Copy link
Owner

@BrianAker Sorry for delay with the answer. I really appreciate the great work which you done and results you achieved. If until today your changes works without any problems please make PR (merge request).

Please take into account that today in version 1.0.9 I fixed compatibility for ESPHome 2022.11.x. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants