Is there any chance to add Support for the IHT-2pb bluetooth BBC thermometer?
BR
Thomas
I would like to second this request.
If I can provide any necessary data, I’m glad to do so. But you would need to advise me, as I have no experience in this field.
If you have a ESP32 device sitting around, I have created an ESPHome project to add Inkbird-ITH-2PB to home assistant.
First of all: Sry for the late reply. I had my notifications settings wrong…
Second: Thank you very much for this project. On a “standard” esp32 development board (like this) it worked right out of the box.
On a esp32-c3 board I had to use another .yaml.
esp32-c3 yaml
esphome:
name: testesp32c3
friendly_name: testEsp32C3
on_boot: #this is to avoid slow startup time because of BT and WiFi "interactions?" , check https://github.com/esphome/issues/issues/2941#issuecomment-1331851692
priority: 250
then:
#- delay: 15s
- wait_until:
condition:
wifi.connected:
#- lambda: |-
# id(ble_tracker).set_scan_continuous(true);
# id(ble_tracker).start_scan();
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
#type: esp-idf
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: !secret encryption_key
ota:
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: !secret wifi_fallback_ssid
password: !secret wifi_fallback_password
captive_portal:
bluetooth_proxy:
active: true
esp32_ble_tracker:
id: ble_tracker
#scan_parameters:
# continuous: false
scan_parameters:
interval: 1100ms
window: 1100ms
active: true
# Inkbird handheld thermometer with 1 manual probe and 2 external probes
ble_client:
- mac_address: !secret ble_mac_address_IHT2PB
id: inkbird_IHT_2PB_ble
on_connect:
then:
- lambda: |-
ESP_LOGD("ble_client_lambda", "Connected to BLE device");
id(inkbird_IHT_2PB_connected).publish_state(true);
# We need to add a small delay because on_connect is triggered before the device is fully connected
# see https://github.com/esphome/issues/issues/4153
# But even with a 10ms delay it doesn't seem to work
# - delay: 10ms
# - script.execute: activate_temperature_notifications
on_disconnect:
then:
- lambda: |-
ESP_LOGD("ble_client_lambda", "Disconnected from BLE device");
id(inkbird_IHT_2PB_connected).publish_state(false);
script:
- id: activate_temperature_notifications
then:
- ble_client.ble_write:
id: inkbird_IHT_2PB_ble
service_uuid: 0000ffe0-0000-1000-8000-00805f9b34fb
characteristic_uuid: 0000ffe9-0000-1000-8000-00805f9b34fb
value: [0x55, 0xAA, 0x19, 0x01, 0x00, 0x19]
- ble_client.ble_write:
id: inkbird_IHT_2PB_ble
service_uuid: 0000ffe0-0000-1000-8000-00805f9b34fb
characteristic_uuid: 0000ffe4-0000-1000-8000-00805f9b34fb
value: [0x55, 0xAA, 0x1A, 0x01, 0x00, 0x1A]
# We get the error "Characteristic 0000FFE4-0000-1000-8000-00805F9B34FB does not allow writing"
# but this write is necessary to get temperature notifications
switch:
- platform: ble_client
ble_client_id: inkbird_IHT_2PB_ble
name: "Inkbird IHT-2PB enable"
button:
- platform: template
name: "Inkbird IHT-2PB notification"
on_press:
- script.execute: activate_temperature_notifications
binary_sensor:
- platform: template
name: "Inkbird IHT-2PB connected"
id: inkbird_IHT_2PB_connected
icon: mdi:bluetooth-connect
sensor:
- platform: template
name: "Inkbird IHT-2PB probe manual"
id: inkbird_IHT_2PB_probe0
icon: mdi:thermometer-probe
unit_of_measurement: "°C"
accuracy_decimals: 1
device_class: "temperature"
state_class: "measurement"
- platform: template
name: "Inkbird IHT-2PB probe 1"
id: inkbird_IHT_2PB_probe1
icon: mdi:thermometer-probe
unit_of_measurement: "°C"
accuracy_decimals: 1
device_class: "temperature"
state_class: "measurement"
- platform: template
name: "Inkbird IHT-2PB probe 2"
id: inkbird_IHT_2PB_probe2
icon: mdi:thermometer-probe
unit_of_measurement: "°C"
accuracy_decimals: 1
device_class: "temperature"
state_class: "measurement"
- platform: ble_client
ble_client_id: inkbird_IHT_2PB_ble
type: characteristic
name: "Inkbird IHT-2PB last probe data"
service_uuid: 0000ffe0-0000-1000-8000-00805f9b34fb
characteristic_uuid: 0000ffe4-0000-1000-8000-00805f9b34fb
notify: true
lambda: |-
if (x[2] != 2 && x[2] != 4 && x[2] != 6) {
return -1.0;
}
uint8_t probeNr = x[2] / 2;
float temperature;
if (x[4] >= 254) {
// negative
temperature = (float) ((255 * (x[4] - 255)) + (x[5]-255)) / 10;
} else if (x[4] <= 11){
//positive
temperature = (float) ((255 * x[4]) + x[5]) / 10;
} else {
return -1.0;
}
if (probeNr == 1) {
id(inkbird_IHT_2PB_probe0).publish_state(temperature);
} else if (probeNr == 2) {
id(inkbird_IHT_2PB_probe1).publish_state(temperature);
} else if (probeNr == 3) {
id(inkbird_IHT_2PB_probe2).publish_state(temperature);
}
return (float)probeNr;
I think the main difference was to wait until wifi is connected before doing anything else:
esphome:
name: testesp32c3
friendly_name: testEsp32C3
on_boot: #this is to avoid slow startup time because of BT and WiFi "interactions?" , check https://github.com/esphome/issues/issues/2941#issuecomment-1331851692
priority: 250
then:
#- delay: 15s
- wait_until:
condition:
wifi.connected:
and that I had to use arduino as framework
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
I still had to flash it 2-3 times before it worked (had no temperature readings). Right now I have no issues with it (only ~6 h of testing. I will report back after ~1 month).
I don’t have a esp32-c3 available to test at the moment. But if it works for you then you can open a PR on github.