odya / esphome-powmr-hybrid-inverter

ESPHome config for various PowMr Hybrid Inverter models.
MIT License
115 stars 18 forks source link

PowMr-Inverter as device name causes ESPHome compile to fail #32

Closed Roving-Ronin closed 8 months ago

Roving-Ronin commented 8 months ago

Hi,

Just trying to get an ESP32-S3 to install your code and finding that it always fails.

Trying to trouble shoot it we've gone back to using the ESP32 flashed with a 'base' install from the ESPHome web installer, having it discovered in ESPHome on HA instance. When naming it powmr-inverter it then fails to compile.

If we repeat the steps but call it something else (power-inverter for example) then it compiles and flashes OK. Note: At this point we are still using a default esphome configuration such as the example below, with zero reference to your powmr code:

esphome:
  name: power-inverter
  friendly_name: power-inverter

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

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

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Power-Inverter Fallback Hotspot"
    password: "4pjRugTa49S4"

captive_portal:

If we then try to simply rename the device to 'powmr-inverter', or use this name from the start, we then find that compiling an install again fails. Note: This is again not even using your powmr-inverter code, its simply using powr-inverter as the device name.

To demonstrate this we've started with a default ESPHome install on the ESP32-S3, called it power-inverter and flashed it with that. We've then done a rename in ESPHome and gone to install it and it fails with:

INFO ESPHome 2024.3.1
INFO Reading configuration /config/esphome/power-inverter.yaml...
Updating /config/esphome/power-inverter.yaml to /config/esphome/powmr-inverter.yaml

INFO ESPHome 2024.3.1
INFO Reading configuration /config/esphome/powmr-inverter.yaml...
esphome:
  name: powmr-inverter
  friendly_name: Power-Inverter
  build_path: build/powmr-inverter
  area: ''
  platformio_options: {}
  includes: []
  libraries: []
  name_add_mac_suffix: false
  min_version: 2024.3.1
esp32:
  board: esp32-s3-devkitc-1
  framework:
    version: 2.0.5
    source: ~3.20005.0
    platform_version: platformio/espressif32@5.4.0
    type: arduino
  flash_size: 4MB
  variant: ESP32S3
logger:
  baud_rate: 115200
  tx_buffer_size: 512
  deassert_rts_dtr: false
  hardware_uart: USB_CDC
  level: DEBUG
  logs: {}
api:
  port: 6053
  password: [redacted]
  reboot_timeout: 15min
ota:
  safe_mode: true
  version: 2
  port: 3232
  reboot_timeout: 5min
  num_attempts: 10
wifi:
  ap:
    ssid: [redacted]
    password: [redacted]
    ap_timeout: 1min
  domain: .local
  reboot_timeout: 15min
  power_save_mode: LIGHT
  fast_connect: false
  passive_scan: false
  enable_on_boot: true
  networks:
  - ssid: [redacted]
    password: [redacted]
    priority: 0.0
  use_address: powmr-inverter.local
captive_portal: {}

INFO Configuration is valid!
INFO ESPHome 2024.3.1
INFO Reading configuration /config/esphome/powmr-inverter.yaml...
INFO Generating C++ source...
INFO Core config or version changed, cleaning build files...
INFO Deleting /data/build/powmr-inverter/.pioenvs
INFO Deleting /data/build/powmr-inverter/.piolibdeps
INFO Compiling app...
Processing powmr-inverter (board: esp32-s3-devkitc-1; framework: arduino; platform: platformio/espressif32@5.4.0)
--------------------------------------------------------------------------------
Library Manager: Installing esphome/AsyncTCP-esphome @ 2.1.3
INFO Installing esphome/AsyncTCP-esphome @ 2.1.3
Unpacking  [####################################]  100%
Library Manager: AsyncTCP-esphome@2.1.3 has been installed!
INFO AsyncTCP-esphome@2.1.3 has been installed!
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0
INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0
Unpacking  [####################################]  100%
Library Manager: ESPAsyncWebServer-esphome@3.1.0 has been installed!
INFO ESPAsyncWebServer-esphome@3.1.0 has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
HARDWARE: ESP32S3 240MHz, 320KB RAM, 8MB Flash
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5 
 - toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.1.3
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
Compiling .pioenvs/powmr-inverter/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/api/api_pb2.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/api/api_pb2_service.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/api/api_server.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/api/list_entities.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/api/proto.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/api/subscribe_state.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/api/user_services.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/captive_portal/captive_portal.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/esp32/core.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/esp32/gpio.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/esp32/preferences.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/logger/logger.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/logger/logger_esp32.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/logger/logger_esp8266.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/logger/logger_host.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/logger/logger_libretiny.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/logger/logger_rp2040.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/md5/md5.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/mdns/mdns_component.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/mdns/mdns_esp32.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/mdns/mdns_esp8266.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/mdns/mdns_host.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/mdns/mdns_libretiny.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/mdns/mdns_rp2040.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/network/util.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/ota/ota_backend_arduino_esp32.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/ota/ota_backend_arduino_esp8266.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/ota/ota_backend_arduino_libretiny.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/ota/ota_backend_arduino_rp2040.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/ota/ota_backend_esp_idf.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/ota/ota_component.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/socket/bsd_sockets_impl.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/socket/lwip_raw_tcp_impl.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/socket/lwip_sockets_impl.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/socket/socket.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/web_server_base/web_server_base.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/wifi/wifi_component.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/wifi/wifi_component_esp32_arduino.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/wifi/wifi_component_esp8266.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/wifi/wifi_component_esp_idf.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/wifi/wifi_component_libretiny.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/components/wifi/wifi_component_pico_w.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/application.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/color.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/component.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/component_iterator.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/controller.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/entity_base.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/helpers.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/log.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/ring_buffer.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/scheduler.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/string_ref.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/time.cpp.o
Compiling .pioenvs/powmr-inverter/src/esphome/core/util.cpp.o
Compiling .pioenvs/powmr-inverter/src/helpers/myHelpers.cpp.o
Compiling .pioenvs/powmr-inverter/src/main.cpp.o
Building .pioenvs/powmr-inverter/bootloader.bin
Creating esp32s3 image...
Successfully created esp32s3 image.
Generating partitions .pioenvs/powmr-inverter/partitions.bin
Compiling .pioenvs/powmr-inverter/lib703/AsyncTCP-esphome/AsyncTCP.cpp.o
Compiling .pioenvs/powmr-inverter/lib64d/WiFi/WiFi.cpp.o
In file included from src/helpers/myHelpers.cpp:6:
src/helpers/myHelpers.h:10:57: error: 'esphome::modbus_controller' has not been declared
 void updateUnknownSelect(uint16_t sensorIndex, esphome::modbus_controller::ModbusSelect* selectComp);
                                                         ^~~~~~~~~~~~~~~~~
src/helpers/myHelpers.h:10:88: error: expected ',' or '...' before '*' token
 void updateUnknownSelect(uint16_t sensorIndex, esphome::modbus_controller::ModbusSelect* selectComp);
                                                                                        ^
src/helpers/myHelpers.cpp:19:57: error: 'esphome::modbus_controller' has not been declared
 void updateUnknownSelect(uint16_t sensorIndex, esphome::modbus_controller::ModbusSelect* selectComp)
                                                         ^~~~~~~~~~~~~~~~~
src/helpers/myHelpers.cpp:19:88: error: expected ',' or '...' before '*' token
 void updateUnknownSelect(uint16_t sensorIndex, esphome::modbus_controller::ModbusSelect* selectComp)
                                                                                        ^
src/helpers/myHelpers.cpp: In function 'void updateUnknownSelect(uint16_t, int)':
src/helpers/myHelpers.cpp:22:8: error: 'selectComp' was not declared in this scope
   if (!selectComp->active_index().has_value() || sensorIndex != selectComp->active_index().value()) {
        ^~~~~~~~~~
src/helpers/myHelpers.cpp:22:8: note: suggested alternative: 'select'
   if (!selectComp->active_index().has_value() || sensorIndex != selectComp->active_index().value()) {
        ^~~~~~~~~~
        select
*** [.pioenvs/powmr-inverter/src/helpers/myHelpers.cpp.o] Error 1
========================= [FAILED] Took 33.24 seconds =========================

This is with a new HA install on an i5 CPU, with

ESPHome (Addon) 2024.3.1

HA: Core 2024.3.3 Supervisor 2024.03.1 Operating System 12.1 Frontend 20240307.0

Update: Edited the yaml and storing the extra files in directory '/caravan-inverter' to work with an esp called 'caravan-inverter' (instead of the 'powmr-inverter' that is causing this issue) and ESPHome is able to work fine and compile the firmware.