WeekendWarrior1
I have home assistant running on a laptop with bluetooth.
I have a buncg of xiomi humidity sensors connected and integrated into home assistant using
HACS - BLE monitor plugin. https://github.com/custom-components/ble_monitor
I can connect to powerpal device on the laptop using retrieve_api_key.py script.
I was wondering if it’s possible to integrate this into BLE_Monitor or similar so it uses laptop’s bluetooth rather than an external ESP device.
No need to do this
The external components from github should be enough
Please see here for a discussion on the topic. Main difference is that the Xiaomi temp/humidity sensors send their data via advertisement packets, and don’t require a constant connection.
WeekendWarrior1 Thanks for all your help.
I’m happy that I’ve proven it’s possible to connect to powerpal using script and Arduino.
I’ll go back to trying to get it to work in ESPhome rather than Arduino and test from there.
I’ve tried a couple of different esp devices (shelly 1plus and Nodemcu32).
All known devices have bluetooth disabled. I’ll check kids phones/ laptops are turned off and try again.
Running latest HA and ESPhome (from web updates anyway). I’ll check via CLI.
I tried Arduino 2.06 as well as 1.86
but when I complie:
I get errors and fails to compile:
n file included from src/esphome/components/ble_client/ble_client.cpp:5:0:
src/esphome/components/ble_client/ble_client.h:91:8: error: 'void esphome::ble_client::BLEClient::gap_event_handler(esp_gap_ble_cb_event_t, esp_ble_gap_cb_param_t*)' marked 'override', but does not override
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override;
^
*** [/data/powerpalble/.pioenvs/powerpalble/src/esphome/components/ble_client/ble_client.cpp.o] Error 1
Full log:
INFO Detected timezone 'Australia/Sydney'
INFO Generating C++ source...
INFO Core config or version changed, cleaning build files...
INFO Deleting /data/powerpalble/.pioenvs
INFO Compiling app...
Processing powerpalble (board: nodemcu-32s; framework: arduino; platform: platformio/espressif32 @ 3.5.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- <WiFi> 1.0
|-- <ESPmDNS> 1.0
|-- <Update> 1.0
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/api/api_connection.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/api/api_frame_helper.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/api/api_pb2.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/api/api_pb2_service.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/api/api_server.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/api/list_entities.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/api/proto.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/api/subscribe_state.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/api/user_services.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/ble_client/ble_client.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/esp32/core.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/esp32/gpio_arduino.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/esp32/gpio_idf.cpp.o
Compiling /data/powerpalble/.pioenvs/powerpalble/src/esphome/components/esp32/preferences.cpp.o
In file included from src/esphome/components/ble_client/ble_client.cpp:5:0:
src/esphome/components/ble_client/ble_client.h:91:8: error: 'void esphome::ble_client::BLEClient::gap_event_handler(esp_gap_ble_cb_event_t, esp_ble_gap_cb_param_t*)' marked 'override', but does not override
void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override;
^
*** [/data/powerpalble/.pioenvs/powerpalble/src/esphome/components/ble_client/ble_client.cpp.o] Error 1
========================== [FAILED] Took 5.53 seconds ==========================
My yaml file:
substitutions:
device_name: powerpalble
friendly_name: "powerpalble"
device_ip: 192.168.1.214
#################################
esphome:
name: ${device_name}
# includes:
# - powerpal_ble.cpp
# - powerpal_ble.h
esp32:
board: nodemcu-32s
framework:
type: arduino
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 ]
wifi:
ssid: !secret ssid
password: !secret wifi-password
fast_connect: on
manual_ip:
static_ip: ${device_ip}
gateway: 192.168.1.1
subnet: 255.255.255.0
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "powerpalble"
password: !secret ap-password
api:
password: !secret api-password
ota:
password: !secret ota-password
logger:
# 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: d5:d7:12:2c:68:75
id: powerpal
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"
pairing_code: 667124
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: 0000d32e #optional, component will retrieve from your Powerpal if not set
powerpal_apikey: 1ea7e8b2-4a8f-4e20-8e61-d2120e8c7026 #optional, component will retrieve from your Powerpal if not set
I copied and compiled your yaml on my machine (ubuntu 20.04, ESPHome using docker), docker run --rm -v "${PWD}":/config --net=host -it esphome/esphome:latest compile pencilhead.yaml, and it compiled with no issues.
I am guessing you are using ESPhome through your HASSIO install?
From my experience that seems to lead to countless issues (from what I have seen on the ESPHome discord).
Could you please install ESPHome on a different computer following this guide: Installing ESPHome Manually — ESPHome
And then try compiling again, thanks.
PS.
When running esphome version, I get Version: 2022.5.1
Small update . I tried to work out why this wouldn’t compile under HASSIO/Home assistant.
It seems that esphome version I was running has been deprecated since March 2022.
There is a new version in HA - Settings / Addons. I had to uninstall old version as I think there are leftover files if installing over the top.
I also had to delete build files from powerpal folder to force update.
Location:
/usr/share/hassio/homeassistant/esphome/.esphome/build/
Are you able to shed some light on how you got that going please?
I’ve got a spare M5Stack Atom Lite (I got several for my ESPresense setup and ordered one too many), so it’s already been flashed for ESPresense.
Any suggestions on how to get it to a point where I can use this?
After getting ESPHome installed, you will need to configure the ESPHome yaml (and I am guessing you are trying to connect to a powerpal and not an emerald), so find the project template here: powerpal_ble/powerpal_ble.yaml at 84c460de9b8ea2407cd480e6c43bb83bde49fd64 · WeekendWarrior1/powerpal_ble · GitHub
You will need to update to esp32>board to m5stack-atom and your wifi settings, as well as entering the BLE MAC address of your powerpal, your powerpal pairing code and your number of pulses per kwh.
Instructions on how to get these values can be found here: https://github.com/WeekendWarrior1/powerpal_ble#using-the-esphome-component
When your yaml is all filled out, you use ESPhome to build and flash it to your esp32!
The guides above should cover that, but I am also happy to help if you get stuck.
Brilliant, thanks so much. I was concerned that I’d need to install a whole ESPHome solution to use it, but that’s because I didn’t RTFM about what ESPHome exactly is.
I’ve just written a longer form blog post about how I’ve deployed @WeekendWarrior1’s work here, and some other things we’re doing around energy monitoring in our house.
I had no problem getting it setup, but I haven’t had any luck pushing data to the cloud. The debug message is (correct serial number removed) [09:10:04][W][http_request:082]: HTTP Request failed; URL: https://readings.powerpal.net/api/v1/meter_reading/xxxxxxxx; Error: connection refused
Any debugging suggestions? I acknowledge that you no longer have access to a powerpal. I’m happy and able to do some debugging (MITM the app, etc).
Somewhat related question, would it be difficult to setup a different http export? I’d be interested in exporting to pvoutput.