[Resolved] ESPHome devices will not compile after updating to core-2021.12.1

I have HA running on a Raspberry PI 4, I am not running it in a container. I configured a Sonoff S31 smart plug in ESPHome and flashed it a couple weeks ago by plugging into the PI directly. Everything worked great. Today I wanted to update HA to the latest and then I checked on ESPHome. I see there are updates so I figured I update my devices wirelessly this time.

When I try to update the plug I get the below errors in the log. I am at a loss here. Am I missing Python on my core OS (System Health says the version there)? How do I correct this?

System Health

|Installation Type|Home Assistant OS|
|Virtual Environment|false|
|Python Version|3.9.7|
|Operating System Family|Linux|
|Operating System Version|5.10.63-v8|
|CPU Architecture|aarch64|

Error from ESPHome logs:

INFO Reading configuration /config/esphome/sonoff-s31-switch-1.yaml…
INFO Generating C++ source…
INFO Compiling app…
Processing sonoff-s31-switch-1 (board: esp01_1m; framework: arduino; platform: platformio/espressif8266 @ 2.6.3)

Error: Traceback (most recent call last):
File “/usr/local/lib/python3.9/dist-packages/platformio/main.py”, line 129, in main
cli() # pylint: disable=no-value-for-parameter
File “/usr/local/lib/python3.9/dist-packages/click/core.py”, line 1128, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python3.9/dist-packages/click/core.py”, line 1053, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python3.9/dist-packages/platformio/commands/init.py”, line 44, in invoke
return super(PlatformioCLI, self).invoke(ctx)
File “/usr/local/lib/python3.9/dist-packages/click/core.py”, line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.9/dist-packages/click/core.py”, line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python3.9/dist-packages/click/core.py”, line 754, in invoke
return __callback(*args, **kwargs)
File “/usr/local/lib/python3.9/dist-packages/click/decorators.py”, line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File “/usr/local/lib/python3.9/dist-packages/platformio/commands/run/command.py”, line 134, in cli
File “/usr/local/lib/python3.9/dist-packages/platformio/commands/run/command.py”, line 176, in process_env
result = {“env”: name, “duration”: time(), “succeeded”: ep.process()}
File “/usr/local/lib/python3.9/dist-packages/platformio/commands/run/processor.py”, line 67, in process
result = init_platform(self.options[“platform”]).run(
File “/usr/local/lib/python3.9/dist-packages/platformio/platform/_run.py”, line 60, in run
File “/usr/local/lib/python3.9/dist-packages/platformio/platform/_packages.py”, line 72, in autoinstall_runtime_packages
if self.get_package(name):
File “/usr/local/lib/python3.9/dist-packages/platformio/platform/_packages.py”, line 30, in get_package
return self.pm.get_package(spec or self.get_package_spec(name))
File “/usr/local/lib/python3.9/dist-packages/platformio/package/manager/base.py”, line 236, in get_package
for pkg in self.get_installed():
File “/usr/local/lib/python3.9/dist-packages/platformio/package/manager/base.py”, line 209, in get_installed
pkg = PackageItem(pkg_dir)
File “/usr/local/lib/python3.9/dist-packages/platformio/package/meta.py”, line 405, in init
self.metadata = self.load_meta()
File “/usr/local/lib/python3.9/dist-packages/platformio/package/meta.py”, line 440, in load_meta
return PackageMetaData.load(manifest_path)
File “/usr/local/lib/python3.9/dist-packages/platformio/package/meta.py”, line 391, in load
data = json.load(fp)
File “/usr/lib/python3.9/json/init.py”, line 293, in load
return loads(fp.read(),
File “/usr/lib/python3.9/json/init.py”, line 346, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3.9/json/decoder.py”, line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python3.9/json/decoder.py”, line 355, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)


An unexpected error occurred. Further steps:


I was able to resolve the issue by uninstalling ESPHome and then reinstalling it. Not sure why this happened in the first place.

Note, I exported all my YMAL config files and did a backup first but when in reinstalled I did not have to recreate the YAMAL files, they all came back and the devices connected right away.

I hope this helps someone else.


Had the same issue. Seems to be data stored outside of venv.
To get the storage location
pip freeze | grep platformio