libretiny-eu / libretiny

PlatformIO development platform for IoT modules
http://docs.libretiny.eu/
MIT License
382 stars 55 forks source link

Compile error after switching from fork to esphome: ModuleNotFoundError: No module named 'ltchiptool.util.lvm' #199

Closed TheKamakaZi closed 8 months ago

TheKamakaZi commented 8 months ago

Hi guys,

During my quarterly update of Home Assistant, I migrated from the forked version of libretuya to esphome proper, as it's now merged. Unfortunately, I've hit a snag that I can't seem to resolve.

I keep getting the following error while compiling:

ModuleNotFoundError: No module named 'ltchiptool.util.lvm':
  File "/usr/local/lib/python3.9/dist-packages/platformio/builder/main.py", line 173:
    env.SConscript("$BUILD_SCRIPT")
  File "/config/.esphome/platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/config/.esphome/platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/config/.esphome/platformio/platforms/libretiny/builder/main.py", line 30:
    env.SConscript("utils/env.py", exports="env")
  File "/config/.esphome/platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/config/.esphome/platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/config/.esphome/platformio/platforms/libretiny/builder/utils/env.py", line 11:
    from ltchiptool.util.lvm import LVM

Here's my current config:

esphome:
  name: smartswitch-abb63a

bk72xx:
  board: cb2s

logger:

api:
  password: "[REDACTED]"

ota:
  password: "[REDACTED]"

wifi:
  networks:
    - hidden: true
      ssid: !secret wifi_ssid
      password: !secret wifi_password

  ap:
    ssid: "Smart Switch Fallback Hotspot"
    password: "[REDACTED]"

captive_portal:

button:
  - platform: restart
    name: "Koi Pond Pump Restart"

switch:
  - platform: gpio
    pin: P24
    restore_mode: RESTORE_DEFAULT_ON
    icon: mdi:power
    name: "Smart Switch Relay"
    id: "relay"
    on_turn_on:
      - light.turn_on: statusled
    on_turn_off:
      - light.turn_off: statusled

light:
  - platform: status_led
    id: "statusled"
    pin:
      number: P6
      inverted: true

binary_sensor:
  - platform: gpio
    internal: true
    pin:
      number: P26
      inverted: true      
      mode:
        input: true
        pullup: true
    filters:
      - delayed_off: 10ms
    name: "Smart Switch Button"
    id: "sensor"
    on_click:
      - switch.toggle: relay

Any idea how to get around this?

Cheers

kuba2k2 commented 8 months ago

Please post the complete log so that I can look into that error. Then, try uninstalling the addon or clearing PlatformIO data/cache. I don't know how it's done exactly, but I think that if you uninstall ESPHome and install it again, you'll clear caches but keep your YAMLs.

TheKamakaZi commented 8 months ago

Hey @kuba2k2,

Thanks for the tip of clearing out the esphome cache. Unfortunately, I'm still getting the same result. Below is the complete log output, after clearing out the cache:


INFO ESPHome 2023.10.6
INFO Reading configuration /config/smartswitch-abb63a.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing smartswitch-abb63a (board: cb2s; framework: arduino; platform: libretiny @ 1.4.1)
--------------------------------------------------------------------------------
Platform Manager: Installing libretiny @ 1.4.1
INFO Installing libretiny @ 1.4.1
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Platform Manager: libretiny@1.4.1 has been installed!
INFO libretiny@1.4.1 has been installed!
Tool Manager: Installing git+https://github.com/libretiny-eu/framework-beken-bdk#v2021.06.07
INFO Installing git+https://github.com/libretiny-eu/framework-beken-bdk#v2021.06.07
git version 2.30.2
Cloning into '/config/.esphome/platformio/cache/tmp/pkg-installing-bkqa76je'...
Note: switching to '6491b8c001b737c790cba0bee16e548859d5e6fe'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Updating files: 100% (3077/3077), done.
Tool Manager: framework-beken-bdk@0.0.0+v2021.06.07.sha.6491b8c has been installed!
INFO framework-beken-bdk@0.0.0+v2021.06.07.sha.6491b8c has been installed!
Tool Manager: Installing git+https://github.com/libretiny-eu/ArduinoCore-API#2022.08.24
INFO Installing git+https://github.com/libretiny-eu/ArduinoCore-API#2022.08.24
git version 2.30.2
Cloning into '/config/.esphome/platformio/cache/tmp/pkg-installing-v6k9z04w'...
Note: switching to '237b10a4f6da14bf32e5e0963b7f28865216a60c'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Tool Manager: framework-arduino-api@2022.8.24+sha.237b10a has been installed!
INFO framework-arduino-api@2022.8.24+sha.237b10a has been installed!
Tool Manager: Installing git+https://github.com/libretiny-eu/lwip#2.1.3-bdk
INFO Installing git+https://github.com/libretiny-eu/lwip#2.1.3-bdk
git version 2.30.2
Cloning into '/config/.esphome/platformio/cache/tmp/pkg-installing-9yxtdok6'...
Tool Manager: library-lwip@2.1.3-bdk+sha.4ee4d34 has been installed!
INFO library-lwip@2.1.3-bdk+sha.4ee4d34 has been installed!
Tool Manager: Installing git+https://github.com/libretiny-eu/library-freertos#9.0.0
INFO Installing git+https://github.com/libretiny-eu/library-freertos#9.0.0
git version 2.30.2
Cloning into '/config/.esphome/platformio/cache/tmp/pkg-installing-66us649w'...
Tool Manager: library-freertos@9.0.0+sha.95cc959 has been installed!
INFO library-freertos@9.0.0+sha.95cc959 has been installed!
Tool Manager: Installing git+https://github.com/libretiny-eu/library-freertos-port#2023.05.23
INFO Installing git+https://github.com/libretiny-eu/library-freertos-port#2023.05.23
git version 2.30.2
Cloning into '/config/.esphome/platformio/cache/tmp/pkg-installing-inw6ityi'...
Note: switching to 'a917d936203658704b228bb85f2b2531e43846ca'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Tool Manager: library-freertos-port@2023.5.23+sha.a917d93 has been installed!
INFO library-freertos-port@2023.5.23+sha.a917d93 has been installed!
Tool Manager: Installing git+https://github.com/libretiny-eu/library-flashdb#1.2.0
INFO Installing git+https://github.com/libretiny-eu/library-flashdb#1.2.0
git version 2.30.2
Cloning into '/config/.esphome/platformio/cache/tmp/pkg-installing-i0tgn940'...
Note: switching to 'd5c892f0c545884e9f0de0cf67215e426dc8109d'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Tool Manager: library-flashdb@1.2.0+sha.d5c892f has been installed!
INFO library-flashdb@1.2.0+sha.d5c892f has been installed!
Tool Manager: Installing git+https://github.com/libretiny-eu/library-printf#6.1.0
INFO Installing git+https://github.com/libretiny-eu/library-printf#6.1.0
git version 2.30.2
Cloning into '/config/.esphome/platformio/cache/tmp/pkg-installing-6pcf08r6'...
Note: switching to '28a79bdd114da9c84880537dec2a1399d82823d3'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Tool Manager: library-printf@6.1.0+sha.28a79bd has been installed!
INFO library-printf@6.1.0+sha.28a79bd has been installed!
Tool Manager: Installing git+https://github.com/libretiny-eu/library-uf2ota#5.0.0
INFO Installing git+https://github.com/libretiny-eu/library-uf2ota#5.0.0
git version 2.30.2
Cloning into '/config/.esphome/platformio/cache/tmp/pkg-installing-m6htomft'...
Note: switching to 'f955412ed1b196fb2b09f4470ed54dcd9b026d03'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Tool Manager: library-uf2ota@5.0.0+sha.f955412 has been installed!
INFO library-uf2ota@5.0.0+sha.f955412 has been installed!
Tool Manager: Installing toolchain-gccarmnoneeabi @ ~1.100301.0
INFO Installing toolchain-gccarmnoneeabi @ ~1.100301.0
Downloading  [####################################]  100%          
Unpacking  [####################################]  100%          
Tool Manager: toolchain-gccarmnoneeabi@1.100301.220327 has been installed!
INFO toolchain-gccarmnoneeabi@1.100301.220327 has been installed!
Tool Manager: Installing platformio/tool-scons @ ~4.40502.0
INFO Installing platformio/tool-scons @ ~4.40502.0
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Tool Manager: tool-scons@4.40502.0 has been installed!
INFO tool-scons@4.40502.0 has been installed!
Library Manager: Installing esphome/AsyncTCP-esphome @ 2.0.1
INFO Installing esphome/AsyncTCP-esphome @ 2.0.1
Downloading  [####################################]  100%
Unpacking  [####################################]  100%
Library Manager: AsyncTCP-esphome@2.0.1 has been installed!
INFO AsyncTCP-esphome@2.0.1 has been installed!
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0
INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0
Downloading  [####################################]  100%
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...
ModuleNotFoundError: No module named 'ltchiptool.util.lvm':
  File "/usr/local/lib/python3.9/dist-packages/platformio/builder/main.py", line 173:
    env.SConscript("$BUILD_SCRIPT")
  File "/config/.esphome/platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/config/.esphome/platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/config/.esphome/platformio/platforms/libretiny/builder/main.py", line 30:
    env.SConscript("utils/env.py", exports="env")
  File "/config/.esphome/platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 598:
    return _SConscript(self.fs, *files, **subst_kw)
  File "/config/.esphome/platformio/packages/tool-scons/scons-local-4.5.2/SCons/Script/SConscript.py", line 285:
    exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
  File "/config/.esphome/platformio/platforms/libretiny/builder/utils/env.py", line 11:
    from ltchiptool.util.lvm import LVM
========================= [FAILED] Took 106.81 seconds =========================
TheKamakaZi commented 8 months ago

@kuba2k2, you have permission to shoot me for not reading your reply properly the first time...

I have now wiped my esphome cache, and recreated the container from scratch (I'm running HA Core), and it's working properly now.

Sorry for wasting your time :(