Powerpal smart energy monitor

Has anyone tried using this hacs integeration if yes how to get Powerpal API Authorization Key and Powerpal Device ID?

Have a look around post 39 onwards. Or one of the questions on that python repo leads to some more info.

Hi guys
First of all, thanks to WeekendWarrior1 for writing ā€œGitHub - WeekendWarrior1/powerpal_ble: Collection of code, tools and documentation for data retrieval over BLE from your Powerpalā€

I am using esp32. the problem is, it runs and shows

'BLE Advertised Device found: Name: Powerpal 0000f176, Address: ca:cf:f1:3d:77:75, serviceUUID: 59daabcd-12f4-25a6-7d4f-55961dce4205

Attempting to connect to deviceā€¦

Found our device

Forming a connection to ca:cf:f1:3d:77:75

  • Created client

onConnect

MTU:23

  • Connected to server

Attempting to get battery serviceā€¦

onSecurityRequest

onAuthenticationComplete

auth_cmpl.success`

After this line, it stops and nothing happens.
The only thing that I need is real-time power consumption.

Thank you for your help.

I am new to Home Assistant and this is my first plea for help ā€¦

I thought I would start by getting Powerpal to display in Home Assistant using @mindmelting 's code. To obtain the elusive API, I followed @Dean2706 's instructions, but when I try to configure the patched Powerpal .apk on my Samsung Galaxy S9, I get the error message:

ā€œTypeError: Cannot read property ā€˜mapā€™ of undefinedā€

I have no idea what that means, but I assume it is because that .apk is version 1.16.1, but the current version is 1.24.1?

I am preared to try to remove the security using ā€œapk-mitmā€, but I donā€™t know how to obtain the latest .apk package in order to modify it.

Any advice would be greatly appreciated ā€¦ :grinning:

OK, I should have done this before I posted my ā€œplea for helpā€ ā€¦ :face_with_raised_eyebrow:

A simple Google search pointed me to APKPure and I was able to download the latest Powerpal.apk from Google Play ā€¦

Now to see if I can remove the security restrictions ā€¦ and finally discover the API.

Just wondering if this got committed? Iā€™m finding the same issue, counter resets to 0 when ESP32 rebootsā€¦

Very interesting work :slight_smile:

Iā€™m keen to look more into getting a real time readoutā€¦Iā€™ve done some testing with powerpal pro and it appears to be adaptive to whether the power is changing or not. The update rate is extremely fast under changing loads, e.g. I was turning a kettle on and off and seeing the update interval range from ~1-2 seconds with the powerpal app open in foreground on phone (with BLE turned off on phone so it canā€™t have been directly connected to powerpal unit). Can also see on wireshark the cloud report rate from the pro following this adaptive timing.
With constant load it dropped back to around 30+sec.

This leaves me with a few possible pathways to pursue over the christmas break:

  1. attempt to intercept the powerpal pro cloud reports so they could be consumed directly/locally

  2. figure out how the phone app is able to get such rapid updates via cloud and replicate in the cloud polling home assistant integration, which is what I currently use but currently limited to updates once per 60 seconds (less ideal, prefer local)

  3. The most optimal option: switch to esp32 with the code here and attempt to replicate on BLE whatever the powerpal pro is doing to achieve adaptive real time updates

If anyone has any further info Iā€™m keen to hear it - thanks :slight_smile:

Update:
First, thanks for the work on this - really awesome stuff

The external component ble_client shouldnā€™t be needed any more, but I havenā€™t looked deeply enough to be sure. Iā€™m running just powerpal_ble external, with some small changes to be compatible with current beta branch of esphome ble_client:
find and replace in powerpal_ble.cpp:
a) ā€˜conn_idā€™ with ā€˜get_conn_id()ā€™
b) ā€˜gattc_ifā€™ with ā€˜get_gattc_if()ā€™
c) ā€˜remote_bdaā€™ with ā€˜get_remote_bda()ā€™

With that itā€™s running happily for the past half hour for me. It had no issue just connecting and working first run :slight_smile:

Will play around more tomorrow or maybe next weekend

1 Like

hello, first of all, thanks for sharing this work. Iā€™m really keen to use this.
However I am having trouble usingā€¦I have tried through home assistant and esphome standalone (docker) and same error (attached) - looks like there is a definition conflict during compilation.
This is happening even when using the stock sample powerpal_ble.yaml
Any suggestions? I can work with python but C++ is beyond me :frowning_face:

thanks

1 Like

I have been experiencing the same issue as tlee17, above, on a Mac running HASS in VirtualBox, and on a PC with ESPHome standalone. Same error when compiling to the M5Stack Atomlite, and an M5StackCore. Hope someone can help with this!

When youā€™re replacing gattc_if with get_gattc_if(), do not change it in this line:

void Powerpal::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,

                                   esp_ble_gattc_cb_param_t *param) {

Hopefully that solves the compilation errors.

Iā€™m also seeing this error and am using a M5Stack Atom Lite as well.
Perhaps @WeekendWarrior1 might have some thoughts?

Use the fixes described in this and this comment. Iā€™m running M5 Atom Lite without any issues.

Iā€™m now seeing the same errors as well, even though I havenā€™t changed anything for a few weeks (other than updates). @muneeb1990 just to clarify your point, which file are you proposing needs to be edited? Thanks

Check this PR. I have just configured it 2 days ago with the fix. Note that I have to change more source files for it to compile. ESPHome 2022.11.0 compatibility by ashmckenzie Ā· Pull Request #3 Ā· WeekendWarrior1/esphome Ā· GitHub

Hi Guys, just checking if there was any updates on the fail to compile issue since 2022.11.0 ? Bad timing for me I got my Powerpal a couple of weeks ago with plans to integrate into HA, Iā€™m not much of a coder but Iā€™ve tried using @starryalley version of powerpal_ble & ble_client and compiling as a local source and it still fails when it gets to [.pioenvs/powerpal/src/esphome/components/ble_client/automation.cpp.o] and [.pioenvs/powerpal/src/esphome/components/ble_client/ble_client.cpp.o]

There is a good chance that Iā€™m not doing something right !, but it comes back with these.

virtual bool gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
^
void gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
^
virtual bool gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if,
^

Hey folks, sorry been crazy busy these past few weeks. I finally got around to creating a fork with my changes. More details here. In addition to fixing the compile errors, Iā€™ve also added sensors for timestamp, cost, pulses and watt_hours to use HA REST commands to upload to cloud so you can see your usage in Powerpal app without connecting your phone with the device. This is completely optional though.

This setup is tested and working on ESPHome 2022.11.3.

Bingo @muneeb1990 , Youā€™re a star. compiled with your code, working well. Thanks for your efforts. :+1: Cheers

1 Like

Does anyone know if weekendwarriorā€™s integration is still working for Powerpal energy monitoring? Iā€™ve tried a number of fixes including the one muneeb1990 posted but am still getting the same error as compathack.

Hi @drew-t I got mine working 7 days back with @muneeb1990 code from above here, I copied his ā€œpowerpal_bleā€ & ā€œhttp_requestā€ to my pi4 microSD and pointed the .yaml at it to use as a local source to compile but only for components: [powerpal_ble, http_request] not the ble_client, and that worked well, the only thing is I donā€™t think its pushing to the Powerpal cloud, even after adding my device_id and apikey, but I might have done something wrong my end, hope this helps.