Powerpal smart energy monitor

It may be too late, but you want to do

ping readings.powerpal.net

rather than the full URL like you have.

Its not too late ā€¦

This is the result when I ping readings.powerpal.net:

which looks fine to me.

So, why was I getting the error message shown in the last image in my post #276?

Just a quick confirmation that your script has worked for me ā€¦ yay! Thank you

I used a BLE scanner app on my Android phone to retrieve the MAC address. Itā€™s not on the sticker or the app.

Hereā€™s the output in case anyone else is trying this as well. FYI I havenā€™t done anything else yet; e.g. ESP with ESPHome code etc. but so far so good, I reckon

C:\Users\tfmei\Documents\PlatformIO\powerpal_ble\auth_extraction>python3 retrieve_api_key.py
Your Powerpal MAC address:
Incorrect MAC address formatting, should look like -> xx:xx:xx:xx:xx:xx
Your Powerpal MAC address: xx:xx:xx:xx:xx:xx
Your Powerpal pairing code: yyyyyy
Please confirm that you are NOT connected to the Powerpal via Bluetooth using any devices, and that bluetooth is enabled on your computer, and hit enter to continue...
Connected: True
Paired?: True
Authenticating with pairing_code: yyyyyy, converted: zzzzzz
Auth Success

Attempting to retrieve Powerpal Serial Number...
Retrieved Device Serial:   yyyyyy
Meaning your meter reading endpoint is:  https://readings.powerpal.net/api/v1/meter_reading/yyyyyy

Attempting to retrieve apikey (Powerpal UUID)...
Retrieved apikey: <API key>

Would you like this script to validate your apikey by using it to make a request for your device information from https://readings.powerpal.net/api/v1/device/yyyyyy? (y/n): y
Success! Looks like your Device Serial and apikey were succesfully retrieved! Here is the device information returned from https://readings.powerpal.net/api/ :
{
  "serial_number": "yyyyyy",
  "total_meter_reading_count": 404693,
  "pruned_meter_reading_count": 94470,
  "total_watt_hours": 8958498,
  "total_cost": 3458.5894,
  "first_reading_timestamp": 1652140800,
  "last_reading_timestamp": 1683721680,
  "last_reading_watt_hours": 15,
  "last_reading_cost": 0.0042789998,
  "available_days": 364,
  "first_archived_date": "2021-05-05",
  "last_archived_date": "2023-05-09"
}

Next steps?
If I understand this correctly I can use your code onto an ESP32. This code reads the energy values from the Powerpal device via BLE and creates a couple of sensors to be integrated into Home Assistant, right?

How is data storage handled? Also is the data from the Powerpal still published to the Powerpal cloud?

Looking at the errors in order, it first looks like a DNS error (name does not resolve). The second error seems that it can now resolve the server, but it canā€™t connect. The last error I couldnā€™t easily figure out without jumping into the code and having debug logs. My initial jump off point with it would be checking the payload in the template section to see what it is trying to upload.

Further to the above I tried to adopt/upload the ESPHome code but get an errorā€¦

INFO Reading configuration /config/esphome/esphome-web-36d5b8.yaml...
INFO Detected timezone 'Australia/Sydney'
INFO Generating C++ source...
INFO Compiling app...
Processing esphome-web-36d5b8 (board: esp32dev; framework: arduino; platform: platformio/espressif32 @ 5.3.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- WiFi @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- Update @ 2.0.0
|-- noise-c @ 0.1.4
|   |-- libsodium @ 1.10018.1
Compiling /data/esphome-web-36d5b8/.pioenvs/esphome-web-36d5b8/src/esphome/components/ble_client/ble_client.cpp.o
Compiling /data/esphome-web-36d5b8/.pioenvs/esphome-web-36d5b8/src/esphome/components/mdns/mdns_component.cpp.o
In file included from src/esphome/components/ble_client/ble_client.cpp:5:
src/esphome/components/ble_client/ble_client.h:89:8: error: conflicting return type specified for 'virtual void esphome::ble_client::BLEClient::gattc_event_handler(esp_gattc_cb_event_t, esp_gatt_if_t, esp_ble_gattc_cb_param_t*)'
   void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
        ^~~~~~~~~~~~~~~~~~~
In file included from src/esphome/components/ble_client/ble_client.cpp:4:
src/esphome/components/esp32_ble_tracker/esp32_ble_tracker.h:157:16: note: overridden function is 'virtual bool esphome::esp32_ble_tracker::ESPBTClient::gattc_event_handler(esp_gattc_cb_event_t, esp_gatt_if_t, esp_ble_gattc_cb_param_t*)'
   virtual bool gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
                ^~~~~~~~~~~~~~~~~~~
*** [/data/esphome-web-36d5b8/.pioenvs/esphome-web-36d5b8/src/esphome/components/ble_client/ble_client.cpp.o] Error 1
========================== [FAILED] Took 5.02 seconds ==========================

Any idea what this error means and how I can resolve this?

I tried with another ESP32 variant but get the same error as above - something about ble_client.cpp. Has anyone else tried this recently?

I wish I could troubleshoot this myself but Iā€™m not a developer so other than what looks like an issue in ble_client.cpp I really have no idea how to continue here. Iā€™m on the latest version of ESPHome 2023.5.4.

Happy to provide additional information to get to the bottom of this.

Hey, can you try following the step by step Iā€™ve posted here? You shouldnā€™t need ble_client.cpp at all if youā€™re using my code.

Progress. I was able to compile and upload the code but the sensors are unavailable in Home Assistant. Hereā€™s the log output. What can we derive from this?

ESPHome 2023.5.4
INFO Reading configuration /config/esphome/esphome-web-36d5b8.yaml...
INFO Detected timezone 'Australia/Sydney'
INFO Starting log output from esphome-web-36d5b8.local using esphome API
INFO Successfully connected to esphome-web-36d5b8.local
[01:02:13][I][app:102]: ESPHome version 2023.5.4 compiled on May 27 2023, 00:37:04
[01:02:13][C][wifi:505]: WiFi:
[01:02:13][C][wifi:363]:   Local MAC: AC:67:B2:36:D5:B8
[01:02:13][C][wifi:364]:   SSID: 'xxxxxx'[redacted]
[01:02:13][C][wifi:365]:   IP Address: 192.168.2.107
[01:02:13][C][wifi:367]:   BSSID: 74:AC:B9:xx:xx:xx[redacted]
[01:02:13][C][wifi:368]:   Hostname: 'esphome-web-36d5b8'
[01:02:13][C][wifi:370]:   Signal strength: -51 dB ā–‚ā–„ā–†ā–ˆ
[01:02:13][V][wifi:372]:   Priority: 0.0
[01:02:13][C][wifi:374]:   Channel: 11
[01:02:13][C][wifi:375]:   Subnet: 255.255.255.0
[01:02:13][C][wifi:376]:   Gateway: 192.168.2.1
[01:02:13][C][wifi:377]:   DNS1: 192.168.2.1
[01:02:13][C][wifi:378]:   DNS2: 0.0.0.0
[01:02:13][C][logger:301]: Logger:
[01:02:13][C][logger:302]:   Level: VERY_VERBOSE
[01:02:13][C][logger:303]:   Log Baud Rate: 115200
[01:02:13][C][logger:305]:   Hardware UART: UART0
[01:02:13][C][logger:309]:   Level for 'esp32_ble_tracker': WARN
[01:02:13][C][homeassistant.time:010]: Home Assistant Time:
[01:02:13][C][homeassistant.time:011]:   Timezone: 'AEST-10AEDT,M10.1.0,M4.1.0/3'
[01:02:13][C][restart:068]: Restart Switch 'Powerpal Monitor Reboot'
[01:02:13][C][restart:070]:   Icon: 'mdi:restart'
[01:02:13][C][restart:091]:   Restore Mode: always OFF
[01:02:13][C][esp32_ble:238]: ESP32 BLE:
[01:02:13][C][esp32_ble:240]:   MAC address: AC:67:B2:36:D5:BA
[01:02:13][C][esp32_ble:241]:   IO Capability: none
[01:02:13][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:13][C][ble_client:027]: BLE Client:
[01:02:13][C][ble_client:028]:   Address: EF:A0:EF:16:05:4E
[01:02:13][C][mdns:108]: mDNS:
[01:02:13][C][mdns:109]:   Hostname: esphome-web-36d5b8
[01:02:13][V][mdns:110]:   Services:
[01:02:13][V][mdns:112]:   - _esphomelib, _tcp, 6053
[01:02:13][V][mdns:114]:     TXT: friendly_name = Powerpal Gateway
[01:02:13][V][mdns:114]:     TXT: version = 2023.5.4
[01:02:13][V][mdns:114]:     TXT: mac = ac67b236d5b8
[01:02:13][V][mdns:114]:     TXT: platform = ESP32
[01:02:13][V][mdns:114]:     TXT: board = esp32dev
[01:02:13][V][mdns:114]:     TXT: network = wifi
[01:02:13][C][api:141]:   Using noise encryption: YES
[01:02:13][C][powerpal_ble:013]: POWERPAL
[01:02:13][C][powerpal_ble:014]:  Battery 'Powerpal Battery'
[01:02:13][C][powerpal_ble:014]:    Device Class: 'battery'
[01:02:13][C][powerpal_ble:014]:    State Class: ''
[01:02:13][C][powerpal_ble:014]:    Unit of Measurement: '%'
[01:02:13][C][powerpal_ble:014]:    Accuracy Decimals: 0
[01:02:13][C][powerpal_ble:015]:  Power 'Powerpal Power'
[01:02:13][C][powerpal_ble:015]:    Device Class: 'power'
[01:02:13][C][powerpal_ble:015]:    State Class: 'measurement'
[01:02:13][C][powerpal_ble:015]:    Unit of Measurement: 'W'
[01:02:13][C][powerpal_ble:015]:    Accuracy Decimals: 0
[01:02:13][C][powerpal_ble:016]:  Daily Energy 'Powerpal Daily Energy'
[01:02:13][C][powerpal_ble:016]:    Device Class: 'energy'
[01:02:13][C][powerpal_ble:016]:    State Class: 'total_increasing'
[01:02:13][C][powerpal_ble:016]:    Unit of Measurement: 'kWh'
[01:02:13][C][powerpal_ble:016]:    Accuracy Decimals: 3
[01:02:13][C][powerpal_ble:017]:  Total Energy 'Powerpal Total Energy'
[01:02:13][C][powerpal_ble:017]:    Device Class: 'energy'
[01:02:13][C][powerpal_ble:017]:    State Class: 'total_increasing'
[01:02:13][C][powerpal_ble:017]:    Unit of Measurement: 'kWh'
[01:02:13][C][powerpal_ble:017]:    Accuracy Decimals: 3
[01:02:13][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:14][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:14][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:14][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:16][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:16][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:16][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:16][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:16][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:17][VV][scheduler:226]: Running interval '' with interval=60000 last_execution=635821 (now=695827)
[01:02:18][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:18][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:19][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:19][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:20][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:20][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:21][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:22][VV][api.service:512]: on_ping_request: PingRequest {}
[01:02:22][VV][api.service:043]: send_ping_response: PingResponse {}
[01:02:22][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:23][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:23][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:24][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:24][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:25][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:25][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:25][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:25][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:26][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:26][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:26][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:27][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:27][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:27][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[01:02:28][V][esp32_ble:178]: (BLE) gap_event_handler - 3

Is there something missing in my configuration.yaml?

Can you share your ESP32 yaml? It looks like itā€™s not being able to connect to Powerpal.

Here it is. I used your file as a template and the ESP is within range of the Powerpal

esphome:
  name: esphome-web-36d5b8
  friendly_name: Powerpal Gateway

esp32:
  board: esp32dev
  framework:
    type: arduino

external_components:
  - source:
      type: local
      path: my_components
    components: [powerpal_ble]

# Enable logging
logger:
 level: VERY_VERBOSE
 logs:
  esp32_ble_tracker: WARN

#external_components:
#  - source: github://WeekendWarrior1/esphome@powerpal_ble
#    # requires ble_client because I had to add some small features to authenticate properly
#    components: [ ble_client, powerpal_ble ]

# Enable Home Assistant API
api:
  encryption:
    key: "OFLfpN1uo8xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+Yzo="

ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esphome-Web-36D5B8"
    password: "axxxxxxxxxxxxxxZS"

#captive_portal:

# optional requirement to enable powerpal cloud uploading
#http_request:
#  id: powerpal_cloud_uploader

# optional requirement used with daily energy sensor
time:
  - platform: homeassistant
    id: homeassistant_time

esp32_ble_tracker:

ble_client:
  - mac_address: EF:xx:xx:xx:xx:xx
    id: powerpal

switch:
  - platform: restart
    name: "Powerpal Monitor Reboot"

sensor:
  - platform: powerpal_ble
    ble_client_id: powerpal
    power:
      name: "Powerpal Power"
    daily_energy:
      name: "Powerpal Daily Energy"
    energy:
      name: "Powerpal Total Energy"
    battery_level:
      name: "Powerpal Battery"
# additional sensors from muneeb; added on 27/5/2023
    watt_hours:
        name: "Powerpal Watt Hours_json"
    cost:
       name: "Powerpal Cost_json"
    timestamp:
       name: "Powerpal Timestamp_json"
    pulses:
       name: "Powerpal Pulses_json"
    pairing_code: 907216
    notification_interval: 1
    pulses_per_kwh: 800
    time_id: homeassistant_time # daily energy still works without a time_id, but recommended to include one to properly handle daylight savings, etc.
#    http_request_id: powerpal_cloud_uploader
#    cost_per_kwh: 0.1872 #dollars per kWh
#    powerpal_device_id: 0000abcd #optional, component will retrieve from your Powerpal if not set
#    powerpal_apikey: 4a89e298-b17b-43e7-a0c1-fcd1412e98ef #optional, component will retrieve from your Powerpal if not set

What components/edits do I need in configuration.yaml?

Iā€™m assuming youā€™ve added the correct MAC and pairing code for your Powerpal device in this yaml?

Yes I have, just masked it for the community post. Iā€™m just not sure what integration(s) I need on Home Assistant or are you saying itā€™s definitely the inability for the ESP to connect to the Powerpal device?

I can get readings on the Powerpal app

Is your ESP32 close enough to the device?

Yes, about 3m. Can we get additional data from the ESPHome log?

So which code does esp32_ble refer in the above in the log?

It looks like I have some data. Maybe I didnā€™t wait long enough for earlier attempts. However the other thing I changed is the distance. The ESP32 was 3 meters away and I moved it closer (1m). In both situations the signal strength is about -50db. Is that reliable enough?

Would you be able to take a glance at the log - apologies for the long log but I thought I put it out there so that this can be verified properly? Is that what weā€™re expecting?

ESPHome 2023.5.4
INFO Reading configuration /config/esphome/esphome-web-36d5b8.yaml...
INFO Detected timezone 'Australia/Sydney'
INFO Starting log output from esphome-web-36d5b8.local using esphome API
INFO Successfully connected to esphome-web-36d5b8.local
[12:38:40][I][app:102]: ESPHome version 2023.5.4 compiled on May 27 2023, 00:37:04
[12:38:40][C][wifi:505]: WiFi:
[12:38:40][C][wifi:363]:   Local MAC: AC:67:B2:36:D5:B8
[12:38:40][C][wifi:364]:   SSID: 'The Meier Residence'[redacted]
[12:38:40][C][wifi:365]:   IP Address: 192.168.2.107
[12:38:40][C][wifi:367]:   BSSID: xx:xx:xx:xx:xx:xx [redacted]
[12:38:40][C][wifi:368]:   Hostname: 'esphome-web-36d5b8'
[12:38:40][C][wifi:370]:   Signal strength: -50 dB ā–‚ā–„ā–†ā–ˆ
[12:38:40][V][wifi:372]:   Priority: 0.0
[12:38:40][C][wifi:374]:   Channel: 11
[12:38:40][C][wifi:375]:   Subnet: 255.255.255.0
[12:38:40][C][wifi:376]:   Gateway: 192.168.2.1
[12:38:40][C][wifi:377]:   DNS1: 192.168.2.1
[12:38:40][C][wifi:378]:   DNS2: 0.0.0.0
[12:38:40][C][logger:301]: Logger:
[12:38:40][C][logger:302]:   Level: VERY_VERBOSE
[12:38:40][C][logger:303]:   Log Baud Rate: 115200
[12:38:40][C][homeassistant.time:010]: Home Assistant Time:
[12:38:40][C][homeassistant.time:011]:   Timezone: 'AEST-10AEDT,M10.1.0,M4.1.0/3'
[12:38:40][C][restart:068]: Restart Switch 'Powerpal Monitor Reboot'
[12:38:40][C][restart:070]:   Icon: 'mdi:restart'
[12:38:40][C][restart:091]:   Restore Mode: always OFF
[12:38:40][C][esp32_ble:238]: ESP32 BLE:
[12:38:40][C][esp32_ble:240]:   MAC address: AC:67:B2:36:D5:BA
[12:38:40][C][esp32_ble:241]:   IO Capability: none
[12:38:40][C][ble_client:027]: BLE Client:
[12:38:40][C][ble_client:028]:   Address: xx:xx:xx:xx:xx:xx
[12:38:40][C][mdns:108]: mDNS:
[12:38:40][C][mdns:109]:   Hostname: esphome-web-36d5b8
[12:38:40][V][mdns:110]:   Services:
[12:38:40][V][mdns:112]:   - _esphomelib, _tcp, 6053
[12:38:40][V][mdns:114]:     TXT: friendly_name = Powerpal Gateway
[12:38:40][V][mdns:114]:     TXT: version = 2023.5.4
[12:38:40][V][mdns:114]:     TXT: mac = ac67b236d5b8
[12:38:40][V][mdns:114]:     TXT: platform = ESP32
[12:38:40][C][api:138]: API Server:
[12:38:40][C][api:139]:   Address: esphome-web-36d5b8.local:6053
[12:38:40][C][api:141]:   Using noise encryption: YES
[12:38:40][C][powerpal_ble:013]: POWERPAL
[12:38:40][C][powerpal_ble:014]:  Battery 'Powerpal Battery'
[12:38:40][C][powerpal_ble:014]:    Device Class: 'battery'
[12:38:40][C][powerpal_ble:014]:    State Class: ''
[12:38:40][C][powerpal_ble:014]:    Unit of Measurement: '%'
[12:38:40][C][powerpal_ble:014]:    Accuracy Decimals: 0
[12:38:40][C][powerpal_ble:015]:  Power 'Powerpal Power'
[12:38:40][C][powerpal_ble:015]:    Device Class: 'power'
[12:38:40][C][powerpal_ble:015]:    State Class: 'measurement'
[12:38:40][C][powerpal_ble:015]:    Unit of Measurement: 'W'
[12:38:40][C][powerpal_ble:015]:    Accuracy Decimals: 0
[12:38:40][C][powerpal_ble:016]:  Daily Energy 'Powerpal Daily Energy'
[12:38:40][C][powerpal_ble:016]:    Device Class: 'energy'
[12:38:40][C][powerpal_ble:016]:    State Class: 'total_increasing'
[12:38:40][C][powerpal_ble:016]:    Unit of Measurement: 'kWh'
[12:38:40][C][powerpal_ble:016]:    Accuracy Decimals: 3
[12:38:40][C][powerpal_ble:017]:  Total Energy 'Powerpal Total Energy'
[12:38:41][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:41][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:41][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:43][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:44][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:45][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:46][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:46][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:46][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:46][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:47][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:48][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:48][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:49][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:49][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:49][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:50][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:50][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:50][VV][api.service:512]: on_ping_request: PingRequest {}
[12:38:50][VV][api.service:043]: send_ping_response: PingResponse {}
[12:38:52][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:52][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:52][VV][scheduler:226]: Running interval '' with interval=60000 last_execution=3814885 (now=3874888)
[12:38:52][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:53][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:55][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:55][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:55][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:56][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:56][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:57][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:57][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:58][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:58][V][esp32_ble:206]: (BLE) gattc_event [esp_gatt_if: 4] - 10
[12:38:58][V][esp32_ble_client:114]: [0] [xx:xx:xx:xx:xx:xx] gattc_event_handler: event=10 gattc_if=4
[12:38:58][D][powerpal_ble:379]: [xx:xx:xx:xx:xx:xx] Received Notification
[12:38:58][D][powerpal_ble:390]: Recieved measurement notify event
[12:38:58][D][powerpal_ble:049]: Meaurement: DEC(20): 0x88be72640a000020dc5700200090d003ff00ffff
[12:38:58][I][powerpal_ble:064]: Timestamp: 1685241480, Pulses: 10, Average Watts within interval: 750.000000 W, Daily Pulses: 810
[12:38:58][V][sensor:043]: 'Powerpal Power': Received new state 750.000000
[12:38:58][D][sensor:094]: 'Powerpal Power': Sending state 750.00000 W with 0 decimals of accuracy
[12:38:58][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 2198823709
  state: 750
  missing_state: NO
}
[12:38:58][V][sensor:043]: 'Powerpal Cost_json': Received new state 0.000000
[12:38:58][D][sensor:094]: 'Powerpal Cost_json': Sending state 0.00000  with 11 decimals of accuracy
[12:38:58][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 667259054
  state: 0
  missing_state: NO
}
[12:38:58][V][sensor:043]: 'Powerpal Pulses_json': Received new state 10.000000
[12:38:58][D][sensor:094]: 'Powerpal Pulses_json': Sending state 10.00000  with 0 decimals of accuracy
[12:38:58][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 310469837
  state: 10
  missing_state: NO
}
[12:38:58][V][sensor:043]: 'Powerpal Watt Hours_json': Received new state 8.000000
[12:38:58][D][sensor:094]: 'Powerpal Watt Hours_json': Sending state 8.00000  with 0 decimals of accuracy
[12:38:58][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 4009656983
  state: 8
  missing_state: NO
}
[12:38:59][V][sensor:043]: 'Powerpal Timestamp_json': Received new state 1685241472.000000
[12:38:59][D][sensor:094]: 'Powerpal Timestamp_json': Sending state 1685241472.00000  with 0 decimals of accuracy
[12:38:59][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 2168662107
  state: 1.68524e+09
  missing_state: NO
}
[12:38:59][V][sensor:043]: 'Powerpal Total Energy': Received new state 1.025000
[12:38:59][D][sensor:094]: 'Powerpal Total Energy': Sending state 1.02500 kWh with 3 decimals of accuracy
[12:38:59][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 3727478647
  state: 1.025
  missing_state: NO
}
[12:38:59][V][sensor:043]: 'Powerpal Daily Energy': Received new state 1.025000
[12:38:59][D][sensor:094]: 'Powerpal Daily Energy': Sending state 1.02500 kWh with 3 decimals of accuracy
[12:38:59][VV][api.service:140]: send_sensor_state_response: SensorStateResponse {
  key: 2450714088
  state: 1.025
  missing_state: NO
}
[12:38:59][V][component:204]: Component esp32_ble took a long time for an operation (0.28 s).
[12:38:59][V][component:205]: Components should block for at most 20-30ms.
[12:38:59][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:59][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:38:59][VV][api.service:512]: on_ping_request: PingRequest {}
[12:38:59][VV][api.service:043]: send_ping_response: PingResponse {}
[12:39:00][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:39:00][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:39:00][V][esp32_ble:178]: (BLE) gap_event_handler - 3
[12:39:00][V][esp32_ble:178]: (BLE) gap_event_handler - 3


Yes, seems to be working ok now.

1 Like

Hi Taipan,

Had the exact same issue for a while, the failed ping is a red herring. My ping fails too but the clue was in the Log error (none has no attribute state)
Turns out the rest payload in the configurations.yaml is slightly different depending on how you set up your sensors in esp32. I had pre-named them with the powerpal_gateway name so you will need to find the correct name of your sensor (i jsut added a sensor card and found the name) and update it like I have below.:

payload: >-
       [ {"cost":{{ states.sensor.powerpal_gateway_powerpal_cost_json.state }},"is_peak": false, "pulses":{{ states.sensor.powerpal_gateway_powerpal_pulses_json.state }}, "timestamp": {{ (int(states.sensor.powerpal_gateway_powerpal_timestamp_json.state)//60) * 60 }}, "watt_hours": {{ states.sensor.powerpal_gateway_powerpal_watt_hours_json.state}} } ]

This update needed a HA restart to apply and once it did data started flowing to the cloud app.

Apologies if I have overlooked this request in previous posts, but couldnā€™t find any comments relating to using MITM proxy and IOS 16+.

Iā€™ve successfully loaded mitproxy onto my mac, but accessing the certificate trust certificate settings within IOS 16+ on my phone seems to be blocking my request for the mitm certificate?

Any help much appreciated since retrieving the API key is a major factorā€¦

Have you seen my post on this same thread?

I was able to successfully retrieve the MAC without mitm - simply by using the great script developed by @WeekendWarrior1

I did this on Windows 11 but this should work as well on Mac as long as you have Python on it.

1 Like