fsaris / EspHome-AwoX-BLE-mesh-hub

Custom component for ESPhome that can act as a AwoX BLE mesh hub (Telink mesh)
54 stars 16 forks source link

Build fails when framework is espidf #6

Closed gCode72 closed 1 year ago

gCode72 commented 1 year ago

Hello The attached config file builds and runs on the shelly 1 plus pretty well, without the add of the awox line in the end.

When adding the awox part, taken from https://github.com/fsaris/EspHome-AwoX-BLE-mesh-hub/blob/main/awox-ble-mesh-hub.yaml, the the build crashes.

See ERROR_1 below.

When I replace the board framework type to arduino, then it's building, but of corse the image doesn't run on the shelly.

This happens on an iMac 10.15.7.

I tried also in esphome addon in HA and on a macbook. There I got this error in build.

See ERROR_2 below.

Is board framework type esp-idf not supported, or am I doing something wrong?

Home Assistant 2023.2.5 ESPHome 2023.2.4

ERROR_1: esphome run shelly_1_plus_bt_mqtt.yaml INFO Reading configuration shelly_1_plus_bt_mqtt.yaml... WARNING GPIO4 is a Strapping PIN and should be avoided. Attaching external pullup/down resistors to strapping pins can cause unexpected failures. See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins WARNING GPIO0 is a Strapping PIN and should be avoided. Attaching external pullup/down resistors to strapping pins can cause unexpected failures. See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins INFO Generating C++ source... INFO Compiling app... Processing shelly-plus-1 (board: esp32dev; framework: espidf; platform: platformio/espressif32 @ 5.2.0)

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

CMake Error at .pioenvs/shelly-plus-1/CMakeFiles/git-data/grabRef.cmake:48 (file): file failed to open for reading (No such file or directory):

/Volumes/DatenHD/Giampiero/Documents/espHome/.esphome/build/shelly-plus-1/.pioenvs/shelly-plus-1/CMakeFiles/git-data/head-ref Call Stack (most recent call first): /Volumes/DatenHD/Giampiero/.platformio/packages/framework-espidf/tools/cmake/third_party/GetGitRevisionDescription.cmake:80 (include) /Volumes/DatenHD/Giampiero/.platformio/packages/framework-espidf/tools/cmake/third_party/GetGitRevisionDescription.cmake:90 (get_git_head_revision) /Volumes/DatenHD/Giampiero/.platformio/packages/framework-espidf/tools/cmake/build.cmake:67 (git_describe) /Volumes/DatenHD/Giampiero/.platformio/packages/framework-espidf/tools/cmake/build.cmake:175 (build_get_idf_git_revision) /Volumes/DatenHD/Giampiero/.platformio/packages/framework-espidf/tools/cmake/idf.cmake:50 (build_init) /Volumes/DatenHD/Giampiero/.platformio/packages/framework-espidf/tools/cmake/project.cmake:12 (include) CMakeLists.txt:2 (include)

fatal: Needed a single revision fatal: not a git repository: /Volumes/DatenHD/Giampiero/.platformio/packages/framework-espidf/components/openthread/openthread/../../../.git/modules/components/openthread/openthread

=================================================================================== [FAILED] Took 8.22 seconds ===================================================================================

ERROR_2: INFO Reading configuration /config/esphome/s11.yaml... WARNING GPIO4 is a Strapping PIN and should be avoided. Attaching external pullup/down resistors to strapping pins can cause unexpected failures. See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins WARNING GPIO0 is a Strapping PIN and should be avoided. Attaching external pullup/down resistors to strapping pins can cause unexpected failures. See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins INFO Generating C++ source... INFO Core config or version changed, cleaning build files... INFO Deleting /data/shelly-plus-1/.pioenvs INFO Deleting /data/shelly-plus-1/.piolibdeps INFO Compiling app... Processing shelly-plus-1 (board: esp32dev; framework: espidf; platform: platformio/espressif32 @ 5.2.0)

Library Manager: Installing esphome/noise-c @ 0.1.4 INFO Installing esphome/noise-c @ 0.1.4 Unpacking [####################################] 100% Library Manager: noise-c@0.1.4 has been installed! INFO noise-c@0.1.4 has been installed! Library Manager: Resolving dependencies... INFO Resolving dependencies... Library Manager: Installing esphome/libsodium @ 1.10018.1 INFO Installing esphome/libsodium @ 1.10018.1 Unpacking [####################################] 100%
Library Manager: libsodium@1.10018.1 has been installed! INFO libsodium@1.10018.1 has been installed! Library Manager: Installing bblanchon/ArduinoJson @ 6.18.5 INFO Installing bblanchon/ArduinoJson @ 6.18.5 Unpacking [####################################] 100% Library Manager: ArduinoJson@6.18.5 has been installed! INFO ArduinoJson@6.18.5 has been installed! Library Manager: Installing rweather/Crypto @ 0.4.0 INFO Installing rweather/Crypto @ 0.4.0 Unpacking [####################################] 100% Library Manager: Crypto@0.4.0 has been installed! INFO Crypto@0.4.0 has been installed! HARDWARE: ESP32 160MHz, 320KB RAM, 4MB Flash



shelly_1_plus_bt_mqtt_1.txt

fsaris commented 1 year ago

I only tested with the Arduino platform because then the crypto (AES) dependency is correctly resolved.

Could be that it's something missing in my component config but didn't yet tried to get it running on esp-idf.

It uses the same crypto dependency as https://esphome.io/components/sensor/dsmr.html not sure if that works with esp-idf.

Could be a starting point to get it to work

fsaris commented 1 year ago

If I find some time I will look if I can use mbedtls/aes.h

Like in https://github.com/MarkEvens/AES-Encryption-ESP-IDF/blob/main/main/main.c

gCode72 commented 1 year ago

Hi Frans, that would be very kind. Thanks!

gCode72 commented 1 year ago

If I find some time I will look if I can use mbedtls/aes.h

Like in https://github.com/MarkEvens/AES-Encryption-ESP-IDF/blob/main/main/main.c

Hi there, any news on this?

fsaris commented 1 year ago

Sorry not yet

fsaris commented 1 year ago

@gCode72 could you test the dev branch? The arduino requirement for encryption is removed.

You can use this in the YAML to install the dev version:

external_components:
  - source:
      type: git
      url: https://github.com/fsaris/EspHome-AwoX-BLE-mesh-hub
      ref: dev
gCode72 commented 1 year ago

Hi Frans, Thanks for working on that. I got still build errors. Here is the log. I think my config file is correct.

Log: ESPHome 2023.5.4 INFO Reading configuration shelly_eingang_plus_bt.yaml... INFO Cloning https://github.com/fsaris/EspHome-AwoX-BLE-mesh-hub@dev WARNING GPIO4 is a Strapping PIN and should be avoided. Attaching external pullup/down resistors to strapping pins can cause unexpected failures. See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins WARNING GPIO0 is a Strapping PIN and should be avoided. Attaching external pullup/down resistors to strapping pins can cause unexpected failures. See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins INFO Generating C++ source... INFO Core config or version changed, cleaning build files... INFO Compiling app... Processing shelly-plus-1-eingang (board: esp32dev; framework: espidf; platform: platformio/espressif32@5.3.0)

Library Manager: Installing esphome/noise-c @ 0.1.4 INFO Installing esphome/noise-c @ 0.1.4 Unpacking [####################################] 100% Library Manager: noise-c@0.1.4 has been installed! INFO noise-c@0.1.4 has been installed! Library Manager: Resolving dependencies... INFO Resolving dependencies... Library Manager: Installing esphome/libsodium @ 1.10018.1 INFO Installing esphome/libsodium @ 1.10018.1 Unpacking [####################################] 100% Library Manager: libsodium@1.10018.1 has been installed! INFO libsodium@1.10018.1 has been installed! Library Manager: Installing bblanchon/ArduinoJson @ 6.18.5 INFO Installing bblanchon/ArduinoJson @ 6.18.5 Unpacking [####################################] 100% Library Manager: ArduinoJson@6.18.5 has been installed! INFO ArduinoJson@6.18.5 has been installed! HARDWARE: ESP32 160MHz, 320KB RAM, 4MB Flash

fsaris commented 1 year ago

@gCode72 having the device functioning as switch, Bluetooth proxy and mesh hub will probably be to much.

It's known that the api: and mqtt: can result in rebooting of the device due to memory issues when running the mesh hub.

But that isn't the reason it doesn't build at all :)

gCode72 commented 1 year ago

Thanks for the hints. I will take that into account!

fsaris commented 1 year ago

@gCode72 got it running now with framework esp-idf

Only logging is not working properly when connected by cable but that's probably some missing config on my side. Logging over wifi works properly

gCode72 commented 1 year ago

Hi Frans, It's compiling now, great job! Although I could not get it run on the device. After removing the api config entry (left only mqtt config) the device crashes with error about logger missing (sorry, did not save the log). Have to get if out of the wall first and flashed it by cable before I can retry.

Thanks so far!!

michalpulda commented 1 year ago

Hello, I have compiled the firmware using the esp-idf framework and it works well. I can't really say if there is any difference comparing it to the original arduino framework. They say the esp-idf framework should work better/faster with bluetooth, though. Will come back in a few days to let you know. Thanks!

gCode72 commented 1 year ago

Hello @michalpulda, Great to hear that. Thank you for contributing! You mean, you have flashed your esp32 device, and it works? What kind of device do you use? I tried to flash a Shelly 1 Plus. But I can't really get it to work. Permanent reboot. At that point, I'am not sure if the Shelly is capable for all that. Could you maybe share your config file?

Regards!

michalpulda commented 1 year ago

Hi @gCode72, I'm using regular esp32 devkit (vroom). The config file is rather simple, nothing fancy:

substitutions:
  name: "esp32u-ble-awox"
  friendly_name: "ESP32U BLE Awox"

esphome:
  name: "${name}"
  friendly_name: "${friendly_name}"

esp32:
  board: esp32dev
  framework:
    #type: arduino
    type: esp-idf

wifi:
  ssid: !secret wifi-ssid
  password: !secret wifi-pass
  use_address: 192.168.xxx.xxx

logger:

ota:
  password: !secret ota-pass

mqtt:
  broker: 192.168.xxx.xxx
  username: !secret mqtt_user
  password: !secret mqtt_password

external_components:
  - source:
      type: git
      url: https://github.com/fsaris/EspHome-AwoX-BLE-mesh-hub
      ref: dev # for esp-idf testing

esp32_ble_tracker:
  scan_parameters:
    active: false

awox_mesh:
  mesh_name: !secret mesh_name
  mesh_password: !secret mesh_password
  address_prefix: A4:C1:38:56:C1:CD # bulb right next to the ESP32
  device_info:
  -  product_id: 0x49
     device_type: DIM
     name: Bulb A60 Warm
     model: ESMLm_w9w
     manufacturer: EGLO
     icon: mdi:lightbulb-outline
  -  product_id: 0x33
     device_type: RGB
     name: Spot 170
     model: EGLOSpot 170/w
     manufacturer: EGLO
     icon: mdi:light-recessed
  -  product_id: 0x32
     device_type: RGB
     name: Spot 120
     model: EGLOSpot 120/w
     manufacturer: EGLO
     icon: mdi:light-recessed
  -  product_id: 0x51
     device_type: RGB
     name: TriSpot 85
     model: ETriSpot_85
     manufacturer: EGLO
     icon: mdi:light-recessed
  -  product_id: 0x85
     device_type: PLUG
     name: EGLO PLUG PLUS
     model: SMPWBm10GEa
     manufacturer: EGLO
     icon: mdi:power-socket-de

switch:
  - platform: restart
    name: "${friendly_name} Restart"

binary_sensor:
  - platform: status
    name: "${friendly_name} Status"
dreyks commented 1 year ago

can confirm, managed to build and flash using the config above. my device was already using esp-idf for other stuff and adding awox nearly doubled the firmware size. it took almost all the flash space of my Lilygo stick and took me a couple of tries to push it through the timeouts while doing OTA, but now everything works 👍

gCode72 commented 1 year ago

Hello everyone, I finally also get it work. Now it's working pretty good. Light become unavailable from time to time in HA.

But for me the issue regarding esp-idf framework is fixed.

Again, great work @fsaris. Thanks all who have contributed testing.

Regards!

fsaris commented 1 year ago

Code is merged to the main branch