PowerXtreme / Emergoplus BLE Battery

Hm… no luck yet… I have this in the yaml now:

esphome:
  name: "esp32-12"
  platform: ESP32
  board: wemos_d1_mini32

substitutions:
  esp_name: esp32_12

wifi:
  ssid: "wifi"
  password: !secret wifi_key
  use_address: 192.168.6.95
  domain: !secret domain
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${esp_name} Fallback Hotspot"
    password: !secret Fallback_Hotspot

captive_portal:

# Enable logging
logger:
#    level: VERBOSE
#  baud_rate: 9600

# Enable Home Assistant API
api:

ota:

time:
  - platform: homeassistant
    id: homeassistant_time

web_server:
  port: 80

esp32_ble_tracker:
  scan_parameters: 
    duration: 90s

# Define the BLE client
ble_client:
  - mac_address: "30:55:44:36:66:7D" # Replace with the MAC address of your BLE device
    id: my_ble_client
    on_connect:
      then:
        - lambda: |-
            id(ble_connected) = true;
            id(ble_state) = "connected";
    on_disconnect:
      then:
        - lambda: |-
            id(ble_connected) = false;
            id(ble_state) = "reconnecting";
        - script.execute: reconnect_ble

## To find the mac adress, most easy way is to enable the part down below saying:
##   - platform: ble_scanner
##     name: "BLE Devices Scanner"     
## This will show all found BLE devices in the area with their mac adres and name if they have one in the esphome log.
## In case of a X210 battery the macs start consistently with: DC:0D:30:

sensor:
  - <<: !include includes/include-wifi-signal.yaml
  - <<: !include includes/include-uptime-config.yaml

  - platform: template
    name: "Battery voltage"
    unit_of_measurement: "V"
    update_interval: 30s
    accuracy_decimals: 2
    lambda: |-
      return id(global_voltage);
  - platform: template
    name: "Battery Current"
    update_interval: 30s
    unit_of_measurement: "A"
    accuracy_decimals: 1
    lambda: |-
      return id(global_current);
  - platform: template
    name: "Battery SOC"
    update_interval: 30s
    unit_of_measurement: "%"
    accuracy_decimals: 0
    lambda: |-
      return id(global_soc);
  - platform: template
    name: "Battery Temperature"
    update_interval: 30s
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    lambda: |-
      return id(global_temperature);

#Unsure about these two yet if they actually work and what they mean
  - platform: template
    name: "Battery Status"
    update_interval: 30s
    accuracy_decimals: 0
    lambda: |-
      return id(global_status);
  - platform: template
    name: "Battery AFE Status"
    update_interval: 30s
    accuracy_decimals: 0
    lambda: |-
      return id(global_afe_status);

globals:
  - id: global_voltage
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_current
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_soc
    type: int
    restore_value: no
    initial_value: '0'
  - id: global_temperature
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_status
    type: int
    restore_value: no
    initial_value: '0'
  - id: global_afe_status
    type: int
    restore_value: no
    initial_value: '0'
  - id: ble_connected
    type: bool
    restore_value: no
    initial_value: 'false'
  - id: ble_state
    type: std::string
    restore_value: no
    initial_value: '"disconnected"'    

# this fetches data every minute by pushing a Number 1 to the FFF2 characteristic, causing an update on the Notify FFF1
# Not sure if you actually need these two one, if it keeps dumping so mucht data it might do it itself anyway. 
# You could try removing these

interval:
  - interval: 1min
    then:
      - ble_client.ble_write:
          id: my_ble_client
          service_uuid: 'FFF0'
          characteristic_uuid: 'FFF2'
          value: [0x31]

#this button manually fetches the data by pushing a Number 1 to the FFF2 characteristic, causing an update on the Notify FFF1
button:
  - platform: template
    name: "Force update values"
    on_press:
      then:
        - ble_client.ble_write:
            id: my_ble_client
            service_uuid: 'FFF0'
            characteristic_uuid: 'FFF2'
            value: [0x31]          

text_sensor:
  - <<: !include includes/include-uptime-human.yaml
  - <<: !include includes/include-esphome-version.yaml
  - <<: !include includes/include-wifi-info.yaml

  - platform: template
    name: "Battery BLE connection"
    id: ble_state_sensor
    lambda: |-
      return id(ble_state);

  - platform: ble_client
    ble_client_id: my_ble_client
    name: "BLE Service FFE0 Characteristic FFE4"
    service_uuid: 'FFE0'
    characteristic_uuid: 'FFE4'
    notify: true
    internal: true
    id: ble_raw_data
    on_value:
      then:
        - lambda: |-
            std::string raw_data = id(ble_raw_data).state;
            if (raw_data.length() >= 38) {
              // Strip the first character '^'
              raw_data = raw_data.substr(1);

              auto char_to_int = [](char c) -> int {
                if ('0' <= c && c <= '9') {
                  return c - '0';
                } else if ('A' <= c && c <= 'F') {
                  return (c - 'A') + 10;
                } else {
                  return 0;
                }
              };

              auto asciitochar = [&](char b, char b2) -> int {
                return ((char_to_int(b) << 4) & 0xF0) + (char_to_int(b2) & 0x0F);
              };

              int voltage = (((((asciitochar(raw_data[6], raw_data[7]) << 8) + asciitochar(raw_data[4], raw_data[5])) << 8) + asciitochar(raw_data[2], raw_data[3])) << 8) + asciitochar(raw_data[0], raw_data[1]);
              int current = (((((asciitochar(raw_data[14], raw_data[15]) << 8) + asciitochar(raw_data[12], raw_data[13])) << 8) + asciitochar(raw_data[10], raw_data[11])) << 8) + asciitochar(raw_data[8], raw_data[9]);
              int soc = (asciitochar(raw_data[30], raw_data[31]) << 8) + asciitochar(raw_data[28], raw_data[29]);
              int temperature = (asciitochar(raw_data[34], raw_data[35]) << 8) + asciitochar(raw_data[32], raw_data[33]);
              int status = asciitochar(raw_data[36], raw_data[37]);
              int afe_status = asciitochar(raw_data[40], raw_data[41]);

              float temperature_celsius = (temperature - 0xAAB) / 10.0;
              float voltage_display = voltage / 1000.0;
              float current_display = current / 10.0;

              id(global_voltage) = voltage_display;
              id(global_current) = current_display;
              id(global_soc) = soc;
              id(global_temperature) = temperature_celsius;
              id(global_status) = status;
              id(global_afe_status) = afe_status;
            } else {
              ESP_LOGE("main", "Received raw data is too short.");
            }

  - platform: ble_scanner
    name: "BLE Devices Scanner" 

switch:
  - <<: !include includes/include-generic-restart-switch.yaml

script:
  - id: reconnect_ble
    then:
      - delay: 5s
      - ble_client.connect: my_ble_client
      - delay: 30s
      - if:
          condition:
            lambda: |-
              return !id(ble_connected);
          then:
            - script.execute: reconnect_ble

#https://community.home-assistant.io/t/powerxtreme-emergoplus-ble-battery

EDIT: Think I did needed to add:

  - platform: ble_client
    ble_client_id: my_ble_client
    name: "BLE Service dump 3"
    service_uuid: 'FFE0'
    characteristic_uuid: 'FFE4'
    notify: true
    internal: true

And I commented out:

#  - platform: ble_scanner
#    name: "BLE Devices Scanner"

Because I thought that might fill the logs…

But still no readings. Other errors:

08:41:50][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '07D2'
[08:41:50][E][main:229]: Received raw data is too short.
[08:41:50][D][text_sensor:064]: 'BLE Service dump 3': Sending state '07D2'
[08:41:50][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:41:51][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^EF33000000000000'
[08:41:51][E][main:229]: Received raw data is too short.
[08:41:51][D][text_sensor:064]: 'BLE Service dump 3': Sending state '^EF33000000000000'
[08:41:51][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:41:51][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:41:51][E][main:229]: Received raw data is too short.
[08:41:51][D][text_sensor:064]: 'BLE Service dump 3': Sending state '3075000001005600'
[08:41:51][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:41:51][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '660B00800C94'
[08:41:51][E][main:229]: Received raw data is too short.
[08:41:51][D][text_sensor:064]: 'BLE Service dump 3': Sending state '660B00800C94'
[08:41:51][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:41:51][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'F80CFE0CFF0\xc3FA0C'
[08:41:51][E][main:229]: Received raw data is too short.
[08:41:51][D][text_sensor:064]: 'BLE Service dump 3': Sending state 'F80CFE0CFF0\xc3FA0C'
[08:41:51][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:41:51][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0`00000000000000'
[08:41:51][E][main:229]: Received raw data is too short.
[08:41:51][D][text_sensor:064]: 'BLE Service dump 3': Sending state '0`00000000000000'
[08:41:51][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:41:51][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:41:51][E][main:229]: Received raw data is too short.
[08:41:51][D][text_sensor:064]: 'BLE Service dump 3': Sending state '0000000000000000'
[08:41:51][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:41:51][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '00000`0000000000'
[08:41:51][E][main:229]: Received raw data is too short.
[08:41:51][D][text_sensor:064]: 'BLE Service dump 3': Sending state '00000`0000000000'
[08:41:51][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT

Flooded with a red error:
[08:41:50][E][main:229]: Received raw data is too short.

I really hope this will start working :heart_eyes:

ha interesting, i thought the ‘’ around the data you provided were some weird artifact of copy pasting or the console.

(so i removed all of them leaving me with for example this: ^2134000000000000307500000105600650B00800C94050D0A0D0C0D060D000000000000000000000000000000000000000000000000336)

Looks like its in the actual data.

So i think only thing needed is to remove those pesky quotation marks and newlines.
(Note the two new lines in the lambda of the ble_client).
I can not really test this myself, this is a suggestion from ChatGPT. Let me know if it works or not :slight_smile:

If it works you might want to try reducing the amount of data its processing, for example by setting a global counter initially zero, then on every ble receive in the lambda increase the counter till for example 10, if it hits ten do the rest of the code and reset the counter to 0, so it skips 0 - 9 and does processing only for the 10th receive.

esphome:
  name: "esp32-12"
  platform: ESP32
  board: wemos_d1_mini32

substitutions:
  esp_name: esp32_12

wifi:
  ssid: "wifi"
  password: !secret wifi_key
  use_address: 192.168.6.95
  domain: !secret domain
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${esp_name} Fallback Hotspot"
    password: !secret Fallback_Hotspot

captive_portal:

# Enable logging
logger:
#    level: VERBOSE
#  baud_rate: 9600

# Enable Home Assistant API
api:

ota:

time:
  - platform: homeassistant
    id: homeassistant_time

web_server:
  port: 80

esp32_ble_tracker:
  scan_parameters: 
    duration: 90s

# Define the BLE client
ble_client:
  - mac_address: "30:55:44:36:66:7D" # Replace with the MAC address of your BLE device
    id: my_ble_client
    on_connect:
      then:
        - lambda: |-
            id(ble_connected) = true;
            id(ble_state) = "connected";
    on_disconnect:
      then:
        - lambda: |-
            id(ble_connected) = false;
            id(ble_state) = "reconnecting";
        - script.execute: reconnect_ble

## To find the mac adress, most easy way is to enable the part down below saying:
##   - platform: ble_scanner
##     name: "BLE Devices Scanner"     
## This will show all found BLE devices in the area with their mac adres and name if they have one in the esphome log.
## In case of a X210 battery the macs start consistently with: DC:0D:30:

sensor:
  - <<: !include includes/include-wifi-signal.yaml
  - <<: !include includes/include-uptime-config.yaml

  - platform: template
    name: "Battery voltage"
    unit_of_measurement: "V"
    update_interval: 30s
    accuracy_decimals: 2
    lambda: |-
      return id(global_voltage);
  - platform: template
    name: "Battery Current"
    update_interval: 30s
    unit_of_measurement: "A"
    accuracy_decimals: 1
    lambda: |-
      return id(global_current);
  - platform: template
    name: "Battery SOC"
    update_interval: 30s
    unit_of_measurement: "%"
    accuracy_decimals: 0
    lambda: |-
      return id(global_soc);
  - platform: template
    name: "Battery Temperature"
    update_interval: 30s
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    lambda: |-
      return id(global_temperature);

#Unsure about these two yet if they actually work and what they mean
  - platform: template
    name: "Battery Status"
    update_interval: 30s
    accuracy_decimals: 0
    lambda: |-
      return id(global_status);
  - platform: template
    name: "Battery AFE Status"
    update_interval: 30s
    accuracy_decimals: 0
    lambda: |-
      return id(global_afe_status);

globals:
  - id: global_voltage
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_current
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_soc
    type: int
    restore_value: no
    initial_value: '0'
  - id: global_temperature
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_status
    type: int
    restore_value: no
    initial_value: '0'
  - id: global_afe_status
    type: int
    restore_value: no
    initial_value: '0'
  - id: ble_connected
    type: bool
    restore_value: no
    initial_value: 'false'
  - id: ble_state
    type: std::string
    restore_value: no
    initial_value: '"disconnected"'    

# this fetches data every minute by pushing a Number 1 to the FFF2 characteristic, causing an update on the Notify FFF1
# Not sure if you actually need these two one, if it keeps dumping so mucht data it might do it itself anyway. 
# You could try removing these

interval:
  - interval: 1min
    then:
      - ble_client.ble_write:
          id: my_ble_client
          service_uuid: 'FFF0'
          characteristic_uuid: 'FFF2'
          value: [0x31]

#this button manually fetches the data by pushing a Number 1 to the FFF2 characteristic, causing an update on the Notify FFF1
button:
  - platform: template
    name: "Force update values"
    on_press:
      then:
        - ble_client.ble_write:
            id: my_ble_client
            service_uuid: 'FFF0'
            characteristic_uuid: 'FFF2'
            value: [0x31]          

text_sensor:
  - <<: !include includes/include-uptime-human.yaml
  - <<: !include includes/include-esphome-version.yaml
  - <<: !include includes/include-wifi-info.yaml

  - platform: template
    name: "Battery BLE connection"
    id: ble_state_sensor
    lambda: |-
      return id(ble_state);

  - platform: ble_client
    ble_client_id: my_ble_client
    name: "BLE Service FFE0 Characteristic FFE4"
    service_uuid: 'FFE0'
    characteristic_uuid: 'FFE4'
    notify: true
    internal: true
    id: ble_raw_data
    on_value:
      then:
        - lambda: |-
            std::string raw_data = id(ble_raw_data).state;

            // Remove newlines and single quotes
            raw_data.erase(std::remove(raw_data.begin(), raw_data.end(), '\n'), raw_data.end());
            raw_data.erase(std::remove(raw_data.begin(), raw_data.end(), '\''), raw_data.end());
            
            if (raw_data.length() >= 38) {
              // Strip the first character '^'
              raw_data = raw_data.substr(1);

              auto char_to_int = [](char c) -> int {
                if ('0' <= c && c <= '9') {
                  return c - '0';
                } else if ('A' <= c && c <= 'F') {
                  return (c - 'A') + 10;
                } else {
                  return 0;
                }
              };

              auto asciitochar = [&](char b, char b2) -> int {
                return ((char_to_int(b) << 4) & 0xF0) + (char_to_int(b2) & 0x0F);
              };

              int voltage = (((((asciitochar(raw_data[6], raw_data[7]) << 8) + asciitochar(raw_data[4], raw_data[5])) << 8) + asciitochar(raw_data[2], raw_data[3])) << 8) + asciitochar(raw_data[0], raw_data[1]);
              int current = (((((asciitochar(raw_data[14], raw_data[15]) << 8) + asciitochar(raw_data[12], raw_data[13])) << 8) + asciitochar(raw_data[10], raw_data[11])) << 8) + asciitochar(raw_data[8], raw_data[9]);
              int soc = (asciitochar(raw_data[30], raw_data[31]) << 8) + asciitochar(raw_data[28], raw_data[29]);
              int temperature = (asciitochar(raw_data[34], raw_data[35]) << 8) + asciitochar(raw_data[32], raw_data[33]);
              int status = asciitochar(raw_data[36], raw_data[37]);
              int afe_status = asciitochar(raw_data[40], raw_data[41]);

              float temperature_celsius = (temperature - 0xAAB) / 10.0;
              float voltage_display = voltage / 1000.0;
              float current_display = current / 10.0;

              id(global_voltage) = voltage_display;
              id(global_current) = current_display;
              id(global_soc) = soc;
              id(global_temperature) = temperature_celsius;
              id(global_status) = status;
              id(global_afe_status) = afe_status;
            } else {
              ESP_LOGE("main", "Received raw data is too short.");
            }

  - platform: ble_scanner
    name: "BLE Devices Scanner" 

switch:
  - <<: !include includes/include-generic-restart-switch.yaml

script:
  - id: reconnect_ble
    then:
      - delay: 5s
      - ble_client.connect: my_ble_client
      - delay: 30s
      - if:
          condition:
            lambda: |-
              return !id(ble_connected);
          then:
            - script.execute: reconnect_ble

#https://community.home-assistant.io/t/powerxtreme-emergoplus-ble-battery

Actually, looking at the log part you posted again, looks like its submitting it to the notify in segments?
Then my previous post wont work.
Can you try posting a bit longer result from the logs (like the one you posted with the Other errors, where it says Received data too short) so i can try figuring out if it has a repeating pattern ?
Basicly what needs to happen is identify how many segments it posts and putting them together, then process them. Challange in this is going to determine the start of each set of segments

Its a bit of a guess since i can not properly test, but something like might work, it does compile but since i do not have the same battery its a bit hard to test. As a last resort i could program a second esp to act as the battery.

Note the new global which is a buffer for the incoming strings, every ^ basicly starts the string by looking for it as the first character, then if the character is not found it will add it to the rest, once its found again it will process the data first and reset the string to the new found first segment. This should also solve the issue of flooding the processor for the processing of the strings as its actually quite a few less then assumed but broken up.

If it is still too much data then implementing the counter is still an option.

esphome:
  name: "esp32-12"
  platform: ESP32
  board: wemos_d1_mini32

substitutions:
  esp_name: esp32_12

wifi:
  ssid: "wifi"
  password: !secret wifi_key
  use_address: 192.168.6.95
  domain: !secret domain
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${esp_name} Fallback Hotspot"
    password: !secret Fallback_Hotspot

captive_portal:

# Enable logging
logger:
#    level: VERBOSE
#  baud_rate: 9600

# Enable Home Assistant API
api:

ota:

time:
  - platform: homeassistant
    id: homeassistant_time

web_server:
  port: 80

esp32_ble_tracker:
  scan_parameters: 
    duration: 90s

# Define the BLE client
ble_client:
  - mac_address: "30:55:44:36:66:7D" # Replace with the MAC address of your BLE device
    id: my_ble_client
    on_connect:
      then:
        - lambda: |-
            id(ble_connected) = true;
            id(ble_state) = "connected";
    on_disconnect:
      then:
        - lambda: |-
            id(ble_connected) = false;
            id(ble_state) = "reconnecting";
        - script.execute: reconnect_ble

## To find the mac adress, most easy way is to enable the part down below saying:
##   - platform: ble_scanner
##     name: "BLE Devices Scanner"     
## This will show all found BLE devices in the area with their mac adres and name if they have one in the esphome log.
## In case of a X210 battery the macs start consistently with: DC:0D:30:

sensor:
  - <<: !include includes/include-wifi-signal.yaml
  - <<: !include includes/include-uptime-config.yaml

  - platform: template
    name: "Battery voltage"
    unit_of_measurement: "V"
    update_interval: 30s
    accuracy_decimals: 2
    lambda: |-
      return id(global_voltage);
  - platform: template
    name: "Battery Current"
    update_interval: 30s
    unit_of_measurement: "A"
    accuracy_decimals: 1
    lambda: |-
      return id(global_current);
  - platform: template
    name: "Battery SOC"
    update_interval: 30s
    unit_of_measurement: "%"
    accuracy_decimals: 0
    lambda: |-
      return id(global_soc);
  - platform: template
    name: "Battery Temperature"
    update_interval: 30s
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    lambda: |-
      return id(global_temperature);

#Unsure about these two yet if they actually work and what they mean
  - platform: template
    name: "Battery Status"
    update_interval: 30s
    accuracy_decimals: 0
    lambda: |-
      return id(global_status);
  - platform: template
    name: "Battery AFE Status"
    update_interval: 30s
    accuracy_decimals: 0
    lambda: |-
      return id(global_afe_status);

globals:
  - id: global_voltage
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_current
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_soc
    type: int
    restore_value: no
    initial_value: '0'
  - id: global_temperature
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_status
    type: int
    restore_value: no
    initial_value: '0'
  - id: global_afe_status
    type: int
    restore_value: no
    initial_value: '0'
  - id: ble_connected
    type: bool
    restore_value: no
    initial_value: 'false'
  - id: ble_state
    type: std::string
    restore_value: no
    initial_value: '"disconnected"'
  - id: completed_string
    type: std::string
    restore_value: no
    initial_value: '""'

# this fetches data every minute by pushing a Number 1 to the FFF2 characteristic, causing an update on the Notify FFF1
# Not sure if you actually need these two one, if it keeps dumping so mucht data it might do it itself anyway. 
# You could try removing these

interval:
  - interval: 1min
    then:
      - ble_client.ble_write:
          id: my_ble_client
          service_uuid: 'FFF0'
          characteristic_uuid: 'FFF2'
          value: [0x31]

#this button manually fetches the data by pushing a Number 1 to the FFF2 characteristic, causing an update on the Notify FFF1
button:
  - platform: template
    name: "Force update values"
    on_press:
      then:
        - ble_client.ble_write:
            id: my_ble_client
            service_uuid: 'FFF0'
            characteristic_uuid: 'FFF2'
            value: [0x31]          

text_sensor:
  - <<: !include includes/include-uptime-human.yaml
  - <<: !include includes/include-esphome-version.yaml
  - <<: !include includes/include-wifi-info.yaml

  - platform: template
    name: "Battery BLE connection"
    id: ble_state_sensor
    lambda: |-
      return id(ble_state);

  - platform: ble_client
    ble_client_id: my_ble_client
    name: "BLE Service FFE0 Characteristic FFE4"
    service_uuid: 'FFE0'
    characteristic_uuid: 'FFE4'
    notify: true
    internal: true
    id: ble_raw_data
    on_value:
      then:
        - lambda: |-
            std::string raw_data = id(ble_raw_data).state;

            if (raw_data[0] == '^') {
              if (!id(completed_string).empty()) {
                // Process the completed string
                std::string processed_data = id(completed_string);

                // Parse the processed_data
                auto char_to_int = [](char c) -> int {
                  if ('0' <= c && c <= '9') {
                    return c - '0';
                  } else if ('A' <= c && c <= 'F') {
                    return (c - 'A') + 10;
                  } else {
                    return 0;
                  }
                };

                auto asciitochar = [&](char b, char b2) -> int {
                  return ((char_to_int(b) << 4) & 0xF0) + (char_to_int(b2) & 0x0F);
                };

                if (processed_data.length() >= 38) {  // Adjust the length based on your data structure
                  int voltage = (((((asciitochar(processed_data[6], processed_data[7]) << 8) + asciitochar(processed_data[4], processed_data[5])) << 8) + asciitochar(processed_data[2], processed_data[3])) << 8) + asciitochar(processed_data[0], processed_data[1]);
                  int current = (((((asciitochar(processed_data[14], processed_data[15]) << 8) + asciitochar(processed_data[12], processed_data[13])) << 8) + asciitochar(processed_data[10], processed_data[11])) << 8) + asciitochar(processed_data[8], processed_data[9]);
                  int soc = (asciitochar(processed_data[30], processed_data[31]) << 8) + asciitochar(processed_data[28], processed_data[29]);
                  int temperature = (asciitochar(processed_data[34], processed_data[35]) << 8) + asciitochar(processed_data[32], processed_data[33]);
                  int status = asciitochar(processed_data[36], processed_data[37]);
                  int afe_status = asciitochar(processed_data[40], processed_data[41]);

                  float temperature_celsius = (temperature - 0xAAB) / 10.0;
                  float voltage_display = voltage / 1000.0;
                  float current_display = current / 10.0;

                  id(global_voltage) = voltage_display;
                  id(global_current) = current_display;
                  id(global_soc) = soc;
                  id(global_temperature) = temperature_celsius;
                  id(global_status) = status;
                  id(global_afe_status) = afe_status;
                } else {
                  ESP_LOGE("main", "Received raw data is too short.");
                }
              }

              // Reset the completed_string with the new segment starting with ^
              id(completed_string) = raw_data;
            } else {
              // Append to the existing string
              id(completed_string) += raw_data;
            }

  - platform: ble_scanner
    name: "BLE Devices Scanner" 

switch:
  - <<: !include includes/include-generic-restart-switch.yaml

script:
  - id: reconnect_ble
    then:
      - delay: 5s
      - ble_client.connect: my_ble_client
      - delay: 30s
      - if:
          condition:
            lambda: |-
              return !id(ble_connected);
          then:
            - script.execute: reconnect_ble

#https://community.home-assistant.io/t/powerxtreme-emergoplus-ble-battery

Did you see this?

It’s a bit hard for me to follow you here :sweat_smile:

i must have missed it, anyhow, just try the last code version i posted :slight_smile:
I think it should already have a repeating pattern since every new batch of data starts with the ^, so it might already be solved.

If it does not work ill code up a fake battery later today that acts in the way yours seems to do so i can figure out how to fix it.

I Used the code from post PowerXtreme / Emergoplus BLE Battery - #23 by devilmastah

It’s doing something now, but not totally correct:

One more set of output if it helps:

[08:29:14][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:14][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0`00000000000000'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06EC'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F733000000000000'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'g075000001005600'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FA0CFF0C010DFD0C'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '00000p0000000000'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06EE'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F733000000000000'
[08:29:15][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:15][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3p75000001005600'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FA`C010D010DFC0C'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '05F0'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F833000`00000000'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:16][D][text_sensor:064]: 'BLE Devices Scanner': Sending state '{"timestamp":1719210555,"address":"A4:C1:38:31:9C:E1","rssi":-85,"name":"ATC_319CE1"}'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FA0C010D010DFC0\x87'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:16][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:16][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '000000000`000000'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '05F1'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '\xbeF833000000000000'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '307500000100560`'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FA0CFF0C020DFD0C'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000`00000000000'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F0'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F833000000000000'
[08:29:17][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:17][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00p00C94'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FB0CFF0C020DF\x840C'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '000000`000000000'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F1'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F9330`0000000000'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C9h'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FB0C\x8cF0C020DFD0C'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:18][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:18][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000`00'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F2'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F933000000000000'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005v00'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750\x8600800C94'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FA0C010D010DFD0C'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:19][D][sensor:094]: 'Battery Temperature': Sending state 1775.59998 °C with 1 decimals of accuracy
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '00p0000000000000'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '05F3'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F933000000000000'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '30o5000001005600'
[08:29:19][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:19][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B`0800C94'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FB0CFF0C020DFD0C'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '000000`000000000'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0vF2'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F933000000000000'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'w50B00800C94'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FB0CFF0C020DFD0C'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:20][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:20][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F2'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F833000000000000'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FA0CFF0C020DFD0C'
[08:29:21][D][sensor:094]: 'Battery Status': Sending state 176.00000  with 0 decimals of accuracy
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F0'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^D833000000000000'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:21][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:21][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FB0CFF0C030DFD0C'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F2'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^FA33000000000000'
[08:29:22][D][sensor:094]: 'esp32_12 - WiFi Signal': Sending state -60.00000 dBm with 0 decimals of accuracy
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FB0CFF0C0c0DFD0C'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:22][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:22][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '00`0000000000000'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F4'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F9f3000000000000'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:23][W][ble_client.automation:141]: Cannot write to BLE characteristic - not connected
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'F\x820CFF0C020DFD0C'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000`00000000'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F2'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '\xbcF933000000000000'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_READ_CHAR_EVT
[08:29:23][W][ble_text_sensor:081]: Error reading char at handle 22, status=2
[08:29:23][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:23][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750Bp0800C94'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FB0CFF0C020DFD0C'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F2'
[08:29:24][D][sensor:094]: 'Battery Current': Sending state 0.00000 A with 1 decimals of accuracy
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F833000000000000'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FA0CFF0C020DFD0C'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '00000000000000`0'
[08:29:24][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:24][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '000000000000`000'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F0'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F833000000000000'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FA0CFF0C020DFD0C'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000p00000000'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F0'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^F83300p000000000'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '30750`0001005600'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:25][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750\x8200800C94'
[08:29:25][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FA0BFF0C020DFD0C'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '06F0'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^FC33000000000000'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FB0C010D030DFD0C'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '000`000000000000'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:26][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:26][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '05F9'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^FC33000000000000'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B00800C94'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'FA0C010D030DFD0C'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:27][D][sensor:094]: 'Battery voltage': Sending state 3195.66309 V with 2 decimals of accuracy
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0uF8'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^FB33000000000000'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '307u000001005600'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '750B`0800C94'
[08:29:27][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:27][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state 'F\x810C010D030DFD0C'
[08:29:28][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:28][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:28][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:28][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '00000000000000`0'
[08:29:28][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:28][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '0000000000000000'
[08:29:28][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:28][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '05F7'
[08:29:28][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:28][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '^FD33000000000000'
[08:29:28][D][esp32_ble_client:110]: [0] [30:55:44:36:66:7D] ESP_GATTC_NOTIFY_EVT
[08:29:28][D][text_sensor:064]: 'BLE Service FFE0 Characteristic FFE4': Sending state '3075000001005600'

One annoying thing is as soon if the ESP is in the range of the battery I cannot flash it. It always fails at 4-5%. It must be too busy. Anything doable to that? Filter? Or is it the internals too busy with parsing the messages?

1 Like

I have a powerextreme x125. I guess this must also work for this device?

Try it? Then you’ll know…

I will try it. But I was wondering if someone else already tried.

1 Like

@sender Unfortunately, it did not work. I have a similar as you. These weird numbers do not make sense. I have also the problem that I cannot flash it anymore if it is connected to the battery.

So I would like to start on the beginning to make sure I got the right string.
@devilmastah Which OS app are you using (Do you have a link to the app-store?) and what steps do I need to do to get this long string in the App? Are able to provide this. Can you make your decode script available? Or when I have the string can I sent it to you to see if it is similar?
And lastly, do you see something in the decompile code of the app that different version of the battery are treaded differently?
Sorry for all the questions. Hopefully we can get this to work and when I do I will post also a fully working script.

I had it running partially… it works well, but I cannot “access” the esp anymore (update) if ble is connected. Tried to work it out with the expert (@devilmastah) but he’s not responding anymore… Hope someone else is able to help out because I really like this concept!

My latest running config:

esphome:
  name: "esp32-12"
  platform: ESP32
  board: wemos_d1_mini32

substitutions:
  esp_name: esp32_12

wifi:
  ssid: "wifi"
  password: !secret Iwifi_key
  use_address: 192.168.1.1
  domain: !secret domain
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${esp_name} FH"
    password: !secret FH

captive_portal:

# Enable logging
logger:
#    level: VERBOSE
#  baud_rate: 9600

# Enable Home Assistant API
api:

ota:
  platform: esphome

time:
  - platform: homeassistant
    id: homeassistant_time

web_server:
  port: 80

esp32_ble_tracker:
  scan_parameters: 
    duration: 90s

# Define the BLE client
ble_client:
  - mac_address: "30:55:44:36:77:7D" # Replace with the MAC address of your BLE device
    id: my_ble_client
    on_connect:
      then:
        - lambda: |-
            id(ble_connected) = true;
            id(ble_state) = "connected";
    on_disconnect:
      then:
        - lambda: |-
            id(ble_connected) = false;
            id(ble_state) = "reconnecting";
        - script.execute: reconnect_ble

## To find the mac adress, most easy way is to enable the part down below saying:
##   - platform: ble_scanner
##     name: "BLE Devices Scanner"     
## This will show all found BLE devices in the area with their mac adres and name if they have one in the esphome log.
## In case of a X210 battery the macs start consistently with: DC:0D:30:

sensor:
  - <<: !include includes/include-wifi-signal.yaml
  - <<: !include includes/include-uptime-config.yaml

  - platform: template
    name: "Battery voltage"
    unit_of_measurement: "V"
    update_interval: 30s
    filters:
      - lambda: |
          if (x < 0) return {}; 
          else return x;
    accuracy_decimals: 2
    lambda: |-
      return id(global_voltage);
  - platform: template
    name: "Battery Current"
    update_interval: 30s
    filters:
      - lambda: |
          if (x < 0) return {}; 
          else return x;
    unit_of_measurement: "A"
    accuracy_decimals: 1
    lambda: |-
      return id(global_current);
  - platform: template
    name: "Battery SOC"
    update_interval: 30s
    filters:
      - lambda: |
          if (x < 0) return {}; 
          else return x;
    unit_of_measurement: "%"
    accuracy_decimals: 0
    lambda: |-
      return id(global_soc);
  - platform: template
    name: "Battery Temperature"
    update_interval: 30s
    filters:
      - lambda: |
          if (x < 0) return {}; 
          else return x;
    unit_of_measurement: "°C"
    accuracy_decimals: 1
    lambda: |-
      return id(global_temperature);


globals:
  - id: global_voltage
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_current
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: global_soc
    type: int
    restore_value: no
    initial_value: '0'
  - id: global_temperature
    type: float
    restore_value: no
    initial_value: '0.0'
  - id: ble_connected
    type: bool
    restore_value: no
    initial_value: 'false'
  - id: ble_state
    type: std::string
    restore_value: no
    initial_value: '"disconnected"'
  - id: completed_string
    type: std::string
    restore_value: no
    initial_value: '""'

# this fetches data every minute by pushing a Number 1 to the FFF2 characteristic, causing an update on the Notify FFF1
# Not sure if you actually need these two one, if it keeps dumping so mucht data it might do it itself anyway. 
# You could try removing these

interval:
  - interval: 1min
    then:
      - ble_client.ble_write:
          id: my_ble_client
          service_uuid: 'FFF0'
          characteristic_uuid: 'FFF2'
          value: [0x31]

#this button manually fetches the data by pushing a Number 1 to the FFF2 characteristic, causing an update on the Notify FFF1
button:
  - platform: template
    name: "Force update values"
    on_press:
      then:
        - ble_client.ble_write:
            id: my_ble_client
            service_uuid: 'FFF0'
            characteristic_uuid: 'FFF2'
            value: [0x31]          

text_sensor:
  - <<: !include includes/include-uptime-human.yaml
  - <<: !include includes/include-esphome-version.yaml
  - <<: !include includes/include-wifi-info.yaml

  - platform: template
    name: "Battery BLE connection"
    id: ble_state_sensor
    lambda: |-
      return id(ble_state);

  - platform: ble_client
    ble_client_id: my_ble_client
    name: "BLE Service FFE0 Characteristic FFE4"
    service_uuid: 'FFE0'
    characteristic_uuid: 'FFE4'
    notify: true
    internal: true
    id: ble_raw_data
    on_value:
      then:
        - lambda: |-
            std::string raw_data = id(ble_raw_data).state;

            if (raw_data[0] == '^') {
              if (!id(completed_string).empty()) {
                // Process the completed string
                std::string processed_data = id(completed_string);
                processed_data = processed_data.substr(1);

                // Parse the processed_data
                auto char_to_int = [](char c) -> int {
                  if ('0' <= c && c <= '9') {
                    return c - '0';
                  } else if ('A' <= c && c <= 'F') {
                    return (c - 'A') + 10;
                  } else {
                    return 0;
                  }
                };

                auto asciitochar = [&](char b, char b2) -> int {
                  return ((char_to_int(b) << 4) & 0xF0) + (char_to_int(b2) & 0x0F);
                };

                if (processed_data.length() >= 38) {  // Adjust the length based on your data structure
                  int voltage = (((((asciitochar(processed_data[6], processed_data[7]) << 8) + asciitochar(processed_data[4], processed_data[5])) << 8) + asciitochar(processed_data[2], processed_data[3])) << 8) + asciitochar(processed_data[0], processed_data[1]);
                  int current = (((((asciitochar(processed_data[14], processed_data[15]) << 8) + asciitochar(processed_data[12], processed_data[13])) << 8) + asciitochar(processed_data[10], processed_data[11])) << 8) + asciitochar(processed_data[8], processed_data[9]);
                  int soc = (asciitochar(processed_data[30], processed_data[31]) << 8) + asciitochar(processed_data[28], processed_data[29]);
                  int temperature = (asciitochar(processed_data[34], processed_data[35]) << 8) + asciitochar(processed_data[32], processed_data[33]);

                  float temperature_celsius = (temperature - 0xAAB) / 10.0;
                  float voltage_display = voltage / 1000.0;
                  float current_display = current / 10.0;

                  id(global_voltage) = voltage_display;
                  id(global_current) = current_display;
                  id(global_soc) = soc;
                  id(global_temperature) = temperature_celsius;
                } else {
                  ESP_LOGE("main", "Received raw data is too short.");
                }
              }

              // Reset the completed_string with the new segment starting with ^
              id(completed_string) = raw_data;
            } else {
              // Append to the existing string
              id(completed_string) += raw_data;
            }

#  - platform: ble_scanner
#    name: "BLE Devices Scanner" 

switch:
  - <<: !include includes/include-generic-restart-switch.yaml

script:
  - id: reconnect_ble
    then:
      - delay: 5s
      - ble_client.connect: my_ble_client
      - delay: 30s
      - if:
          condition:
            lambda: |-
              return !id(ble_connected);
          then:
            - script.execute: reconnect_ble