Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- substitutions:
- name: "esphome-ble-bridge"
- friendly_name: "ESP32-S3 BLE Bridge"
- local_tdwlb_lcrppf_mac: !secret tdwlb_lcrppf_mac
- esphome:
- name: ${name}
- friendly_name: ${friendly_name}
- min_version: 2024.6.0
- name_add_mac_suffix: false
- platformio_options:
- board_build.f_flash: 40000000L
- board_build.flash_mode: dio
- board_build.flash_size: 4MB
- esp32:
- board: esp32-s3-devkitc-1
- variant: esp32s3
- framework:
- type: esp-idf
- sdkconfig_options:
- CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
- CONFIG_BT_BLE_50_FEATURES_SUPPORTED: y
- # Enable logging for debugging
- logger:
- level: INFO
- # Enable Home Assistant API
- api:
- # Enable Over-The-Air updates
- ota:
- - platform: esphome
- password: !secret ota_password
- # Allow WiFi provisioning via serial
- improv_serial:
- # WiFi configuration
- wifi:
- ssid: !secret wifi_ssid
- password: !secret wifi_password
- power_save_mode: light
- captive_portal:
- bluetooth_proxy:
- active: true
- esp32_ble_tracker:
- id: ble_tracker
- scan_parameters:
- active: true
- interval: 320ms
- window: 30ms
- ble_client:
- - mac_address: !secret tdwlb_lcrppf_mac
- id: tdwlb_lcrppf
- auto_connect: true
- text_sensor:
- - platform: ble_client
- ble_client_id: tdwlb_lcrppf
- service_uuid: "180A"
- characteristic_uuid: "2A24"
- name: "Model Number"
- icon: "mdi:information-outline"
- id: pressure_sensor_model_number
- - platform: ble_client
- ble_client_id: tdwlb_lcrppf
- service_uuid: "180A"
- characteristic_uuid: "2A29"
- name: "Manufacturer"
- icon: "mdi:information-outline"
- id: pressure_sensor_manufacturer
- - platform: ble_client
- ble_client_id: tdwlb_lcrppf
- service_uuid: "180A"
- characteristic_uuid: "2A25"
- name: "Serial Number"
- icon: "mdi:information-outline"
- id: pressure_sensor_serial_number
- - platform: ble_client
- ble_client_id: tdwlb_lcrppf
- service_uuid: "180A"
- characteristic_uuid: "2A26"
- name: "Firmware Revision"
- icon: "mdi:information-outline"
- id: pressure_sensor_firmware_revision
- sensor:
- # Pressure sensor
- - platform: ble_client
- ble_client_id: tdwlb_lcrppf
- type: characteristic
- service_uuid: "CC4A6A80-51E0-11E3-B451-0002A5D5C51B"
- characteristic_uuid: "835AB4C0-51E4-11E3-A5BD-0002A5D5C51B"
- name: "Tank Pressure"
- unit_of_measurement: "psi"
- accuracy_decimals: 1
- device_class: "pressure"
- notify: true
- lambda: |-
- // Extract the 16-bit unsigned integer raw value from the byte array
- uint16_t raw = (x[0] << 8) | x[1];
- // Scale the raw value directly
- float pressure_psi = raw / 10.0;
- return pressure_psi;
- # Temperature sensor
- - platform: ble_client
- ble_client_id: tdwlb_lcrppf
- type: characteristic
- service_uuid: "CC4A6A80-51E0-11E3-B451-0002A5D5C51B"
- characteristic_uuid: "2A1C"
- name: "Tank Temperature"
- id: tank_temperature
- unit_of_measurement: "°F"
- accuracy_decimals: 1
- device_class: "temperature"
- notify: true
- lambda: |-
- // Extract the first byte that contains the internal / external flag bit (bit 3)
- uint8_t flag = x[0];
- // Extract the 32-bit raw value from the byte array
- uint32_t temp_raw = (x[1] << 24) | (x[2] << 16) | (x[3] << 8) | x[4];
- // Convert to signed float representing °C
- float celsius = *reinterpret_cast<float*>(&temp_raw);
- // convert to °F
- float farenheit = celsius * 9.0 / 5.0 + 32.0;
- return farenheit;
- # Battery level
- - platform: ble_client
- ble_client_id: tdwlb_lcrppf
- type: characteristic
- service_uuid: "180F"
- characteristic_uuid: "2A19"
- name: "Battery Level"
- unit_of_measurement: "%"
- icon: "mdi:battery"
- update_interval: 60s
- button:
- - platform: safe_mode
- id: button_safe_mode
- name: Safe Mode Boot
- - platform: factory_reset
- id: factory_reset_btn
- name: Factory reset
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement