custom-components / ble_monitor

BLE monitor for passive BLE sensors
https://community.home-assistant.io/t/passive-ble-monitor-integration/
MIT License
1.89k stars 243 forks source link

Inkbird iBBQ support #585

Closed aherbjornsen closed 2 years ago

aherbjornsen commented 2 years ago

Is it possible to implement support for the Inkbird iBBQ thermometer range?

I've found out that there are a lot of generic bluetooth barbecue thermometers that are compatible with this brand.

They come in variants with 2, 4 and 6 sensors and you will find a working ESPHome implementation discussed in these threads: https://github.com/esphome/feature-requests/issues/397 https://community.home-assistant.io/t/inkbird-bt-thermometer-ibbq-with-esp32/325825

The BLE announcements look like this for my 2 sensor thermometer:

2021-12-16 07:45:44 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e23020100007bf4abb51434170201060302f0ff0fff000000003414b5abf47bc800d200e5
2021-12-16 07:45:46 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e23020100007bf4abb51434170201060302f0ff0fff000000003414b5abf47bc800d200e1
2021-12-16 07:45:48 INFO (Thread-4) [custom_components.ble_monitor.ble_parser] Unknown advertisement received: 043e23020100007bf4abb51434170201060302f0ff0fff000000003414b5abf47bc800d200e2

This works for me with the following ESPHome config:

esp32_ble_tracker:
  on_ble_advertise:
    - mac_address: 34:14:b5:ab:f4:7b
      then:
        - script.stop: timer
        - lambda: |-
            if (x.get_name() != "iBBQ") return;

            ESP_LOGI("ble_adv", "New BLE device");
            ESP_LOGI("ble_adv", "  address: %s", x.address_str().c_str());
            ESP_LOGI("ble_adv", "  name: %s", x.get_name().c_str());
            ESP_LOGI("ble_adv", "  Advertised service UUIDs:");

            for (auto uuid : x.get_service_uuids()) {
              ESP_LOGI("ble_adv", "    - %s", uuid.to_string().c_str());
            }

            ESP_LOGI("ble_adv", "  Advertised service data:");

            for (auto data : x.get_service_datas()) {
              ESP_LOGI("ble_adv", "    - %s: (length %i)", data.uuid.to_string().c_str(), data.data.size());
            }

            ESP_LOGI("ble_adv", "  Advertised manufacturer data:");

            for (auto data : x.get_manufacturer_datas()) {
              ESP_LOGI("ble_adv", "    - %s: (%s)", data.uuid.to_string().c_str(), hexencode(data.data).c_str());

              if (data.uuid.contains(0, 0)) {

                int probe0 = (data.data[9] << 8) + data.data[8];
                int probe1 = (data.data[11] << 8) + data.data[10];

                ESP_LOGI("ble_data", "    - %f %f", probe0 / 10.0, probe1 / 10.0);

                if (probe0 < 60000) {
                  id(ble_sensor_1).publish_state(probe0 / 10.0);
                } else {
                  id(ble_sensor_1).publish_state(0);                
                }

                if (probe1 < 60000) {
                  id(ble_sensor_2).publish_state(probe1 / 10.0);
                } else {
                  id(ble_sensor_2).publish_state(0);                
                }
              }
            }
        - script.execute: timer

sensor:
  - platform: template
    name: "iBBQ Temperature Probe 1"
    id: ble_sensor_1
    unit_of_measurement: "°C"
    accuracy_decimals: 0
  - platform: template
    name: "iBBQ Temperature Probe 2"
    id: ble_sensor_2
    unit_of_measurement: "°C"
    accuracy_decimals: 0
Ernst79 commented 2 years ago

@aherbjornsen Yes, it seems possible to implement this. The sensors report 20 and 21 degrees. {'firmware': 'Inkbird', 'temperature 1': 20.0, 'temperature 2': 21.0, 'rssi': -27, 'mac': '3414B5ABF47B', 'type': 'iBBQ (2 sensors)', 'packet': 'no packet id', 'data': True}

I will take care of it. But its a little bit more work, due to the 2nd temperature sensor.

aherbjornsen commented 2 years ago

@Ernst79 Thanks. There's still some time until BBQ-season, at least up here in Norway, so there's no rush :-)

Ernst79 commented 2 years ago

I’ve released 6.4.1-beta, please give it a try

aherbjornsen commented 2 years ago

I just installed 6.4.3-beta and see that the device is recognized and added. I get three sensors:

sensor.ble_temperature_probe_1_3414b5abf47b sensor.ble_temperature_probe_2_3414b5abf47b sensor.ble_rssi_3414b5abf47b

The reported values seems to be correct.

Thanks a lot! I will continue to test this a bit more and will report back if there are any problems.

Ernst79 commented 2 years ago

6.4.3 has been released with support for this device, as final.