Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESPHome Compilation Errors (example yaml) with ESPHome v2022.12.3 #3

Open
benh-au opened this issue Jan 22, 2023 · 12 comments
Open

ESPHome Compilation Errors (example yaml) with ESPHome v2022.12.3 #3

benh-au opened this issue Jan 22, 2023 · 12 comments

Comments

@benh-au
Copy link

benh-au commented Jan 22, 2023

Using the example powerpal_ble.yaml, and ESPHome v2012.12.3 (simply changing the board from "wemos_d1_mini32" to "esp32dev")- the Install compilation consistently fails with errors relating to the ble_tracker.cpp component and in incompatible return type.

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:182: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/powerpalble/.pioenvs/powerpalble/src/esphome/components/ble_client/ble_client.cpp.o] Error 1

ESPHome yaml file and compile log are attached.

Is this a possibly a breaking change in the ESPHome core framework since your powerpal_ble component was devised? I'm sorry that I'm new to ESPHome custom components and framework source code, so I can only report to you what I'm encountering - not sure what code changes might resolve these errors.

Compile Log: logs_powerpalble-3e5538_compile_errors.txt
YAML File: powerpalble-3e5538_yaml.txt

@Timmwardion
Copy link

Same issues for me plus a couple of others

INFO Reading configuration /config/esphome/powerpal.yaml...
INFO Detected timezone 'Australia/Sydney'
INFO Generating C++ source...
INFO Compiling app...
Processing powerpal (board: esp32dev; framework: arduino; platform: platformio/espressif32 @ 5.2.0)

HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash

  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
    LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
    Dependency Graph
    |-- WiFi @ 2.0.0
    |-- ESPmDNS @ 2.0.0
    |-- Update @ 2.0.0
    Compiling /data/powerpal/.pioenvs/powerpal/src/esphome/components/ble_client/ble_client.cpp.o
    Compiling /data/powerpal/.pioenvs/powerpal/src/esphome/components/powerpal_ble/powerpal_ble.cpp.o
    Compiling /data/powerpal/.pioenvs/powerpal/src/esphome/components/wifi/wifi_component_esp_idf.cpp.o
    Compiling /data/powerpal/.pioenvs/powerpal/src/esphome/components/wifi/wifi_component_pico_w.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:182: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/powerpal/.pioenvs/powerpal/src/esphome/components/ble_client/ble_client.cpp.o] Error 1
    In file included from src/esphome/components/powerpal_ble/powerpal_ble.h:4,
    from src/esphome/components/powerpal_ble/powerpal_ble.cpp:1:
    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.h:5,
    from src/esphome/components/powerpal_ble/powerpal_ble.h:4,
    from src/esphome/components/powerpal_ble/powerpal_ble.cpp:1:
    src/esphome/components/esp32_ble_tracker/esp32_ble_tracker.h:182: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/powerpal/.pioenvs/powerpal/src/esphome/components/powerpal_ble/powerpal_ble.cpp.o] Error 1
    ========================= [FAILED] Took 16.25 seconds =========================

@pencilhead1
Copy link

I have same issue:
I'm trying to compile powerpal config in ESPHOME using latest version 2023.2.1
I've re-downloaded/installed latest version of powerpal.

Powerpal works with previous versions, but HA has deprecated "AP password" for "AP KEY" and all my ESPHome devices need updating.

Configuration

YAML


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 ]

# 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:xx:xxx:xx
    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-xxxxxxxxxxxx #optional, component will retrieve from your Powerpal if not set

Compilation Logs

Processing somfy (board: nodemcu-32s; framework: arduino; platform: platformio/espressif32 @ 5.2.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch3
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
Dependency Graph
|-- SPI @ 2.0.0
|-- EEPROM @ 2.0.0
|-- SmartRC-CC1101-Driver-Lib @ 2.5.7
|-- Somfy_Remote_Lib @ 0.4.1
|-- WiFi @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- Update @ 2.0.0
|-- ArduinoJson @ 6.18.5
|-- WiFiClientSecure @ 2.0.0
|-- HTTPClient @ 2.0.0
Compiling /data/somfy/.pioenvs/somfy/src/esphome/components/ble_client/ble_client.cpp.o
Compiling /data/somfy/.pioenvs/somfy/src/esphome/components/json/json_util.cpp.o
Compiling /data/somfy/.pioenvs/somfy/src/esphome/components/logger/logger.cpp.o
Compiling /data/somfy/.pioenvs/somfy/src/esphome/components/md5/md5.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/somfy/.pioenvs/somfy/src/esphome/components/ble_client/ble_client.cpp.o] Error 1
========================== [FAILED] Took 3.68 seconds ==========================

@HSB-collab
Copy link

The fork created by @muneeb1990 (https://github.com/muneeb1990/esphome/tree/powerpal_ble/esphome/components/powerpal_ble) seems to solve this problem. However, do not use a local ble_client in the external components.

@CV8R
Copy link

CV8R commented May 11, 2023

Same compile problem for me and sadly this is the first time I have used ESPHome so no clue how to fix it!

@HSB-collab
Copy link

@CV8R I solved the problem by doing the following:
Instead of pulling the code for the external components from weekendwarrior’s Github site you create the external components for powerpal_ble locally in Home-Assistant by:
Under config/esphome folder create a folder called ‘my_components’.
Inside ‘my_components’ create another folder called ‘powepal_ble’
Then download the files referred to by @muneeb1990.
To download files from Github you have to view the file and then click the ‘RAW’ button. You can either copy and paste the RAW data into a file created in Home-Assistant, or save the file on you local computer and transfer it using SAMBA
NOTE: confusingly the init.py file is empty but must be in the powerpal_ble folder.
Now change the powerpal-gateway.yaml file to reference the external components locally by putting the following into the ESPhome config folder:

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

I hope this helps

@KmanOz
Copy link

KmanOz commented Jan 19, 2024

@HSB-collab Thanks. Invaluable info and can confirm it works well with Home Assistant in 2024.

@HSB-collab
Copy link

@HSB-collab Thanks. Invaluable info and can confirm it works well with Home Assistant in 2024.

Actually @KmanOz there is a better solution because @muneeb1990 has put the solution on his github site due to another breaking change - see https://community.home-assistant.io/t/powerpal-smart-energy-monitor/263713/312.
To quote from this thread:
"You can now replace the external_components section of yaml file with:
external_components:

  • source:
    type: git
    url: https://github.com/muneeb1990/esphome
    ref: powerpal_ble
    components: [ powerpal_ble ]
    This will always pull the most up-to-date code without having to store a local copy of powerpal_ble folder."

@rob-deutsch
Copy link

Actually @KmanOz there is a better solution because @muneeb1990 has put the solution on his github site due to another breaking change - see https://community.home-assistant.io/t/powerpal-smart-energy-monitor/263713/312.

Confirmed that this worked for me and ESPHome compiled.

@kaizersoje
Copy link

Hi @muneeb1990, I noticed your code does not contain the code for uploading the data to powerpal. However, this facility is available in @WeekendWarrior1's code. Any reason why this was not done?

I tried to copy parts of the code from @WeekendWarrior1 to yours. But it didn't work.

@pencilhead1
Copy link

pencilhead1 commented Jul 26, 2024

Code I'm using:
Powerpal app still works (make sure phone isn't connected to PP device)

ble_client:
  - mac_address: <my pp mac address>
    id: powerpal

globals:
  - id: powerpal_daily_pulses_backup
    type: int
    restore_value: true

http_request:
  id: powerpal_cloud_uploader
  verify_ssl: false    

sensor:
  - platform: powerpal_ble
    id: powerpal_ble_sensor
    ble_client_id: powerpal
    power:
      name: "Powerpal Power"
    daily_energy:
      name: "Powerpal Daily Energy"
    #daily_pulses:
    #  name: "Powerpal Daily Pulses"
    energy:
      name: "Powerpal Total Energy"
    battery_level:
      name: "Powerpal Battery"
    watt_hours:
       name: "Powerpal Watt Hours_json"
    cost:
       name: "Powerpal Cost_json"
    timestamp:
       name: "Powerpal Timestamp_json"
    pulses:
       name: "Powerpal Pulses_json"
    #watt_hours:
    #  name: "Powerpal Average Watts within interval"   

    pairing_code: <pairing code>
    notification_interval: 1
    pulses_per_kwh: 1000
    time_id: homeassistant_time # daily energy still works without a time_id, but recommended to include one to properly handle daylight savings, etc.
    cost_per_kwh: 0.3145  #dollars per kWh

    powerpal_device_id: <device id> #optional, component will retrieve from your Powerpal if not set
    powerpal_apikey: <api key> #optional, component will retrieve from your Powerpal if not set

  - platform: homeassistant
    id: ha_daily_pulses
    entity_id: sensor.powerpal_daily_pulses
    on_value:
     then:
       - globals.set:
          id: powerpal_daily_pulses_backup
          value: !lambda 'return int(x);'

preferences:
 flash_write_interval: 10min

In home assistant, I have Automation:

alias: Powerpal Cloud Upload
description: Powerpal cloud upload
trigger:
 - platform: time_pattern
   minutes: /1
condition: []
action:
 - service: rest_command.my_request
   data: {}
mode: single

This seems to work.
NB: uploader needs to be every 60 seconds

@kaizersoje
Copy link

What's the rest command?

@pencilhead1
Copy link

From:
https://community.home-assistant.io/t/powerpal-smart-energy-monitor/263713/264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants