ESPHome Error: Could not load broken JSON: /data/cache/platformio/packages/framework-arduinoespressif32/.piopm

Hi guys,

I migrated my HASSIO from a Pi3 to a Pi4 2 days ago
Works great and faster and all
BUT
Since then, I get this error message when I try to compile something in ESPHome …

" Error: Could not load broken JSON: /data/cache/platformio/packages/framework-arduinoespressif32/.piopm"

The YAML I am trying to upload now is the same as I used before (it’s for ESP32-Cam’s)
Tried it on other ESP32 boards too
I get the same error whet I hit the “update” or “update all” in ESPHome

I found a few topics about it already like this one Error: Could not load broken JSON: /data/cache/platformio/platforms/espressif32/.piopm
But the author’s solution is not very clear to me to be honest ^^
Plus I am not running the docker OS

Thanks to those who will have a look at my query!

Delete and reinstall the ESPHome addon.

You won’t lose anything.

Yes I forgot to mention I did that a few times already, as well as a couple system reboots …

Actually, when I uninstall ESPHome, reboot the server, reinstall ESPHome, I get a 502 Bad Gateway on ESPHome, that only disappears when I restart the server again

After restart it works but I get the error message that started this topic…

After repeating the same steps over again, it was fixed. I don’t really know what I did differently this, like, 8th time, but here are the exact steps I followed:

1 Uninstall ESPHome
2 Restart server (I did that physically and left the power plug out of the Pi for a good 5 minutes, maybe that helped but I tried that before)
3 After server restart, reinstall ESPHome
4 DON’T START ESPHOME WHEN INSTALLED, First restart server (I did it that way, but this time, via the restart button in the settings)
5 Start ESPHome, should be up and running, ready to compile and write

Good luck if you encounter this issue, hope it will help!

2 Likes

Thank you for this post.

I just had this exact error when I tried to change one of my esphome device from arduino to esp-idf type, and then when compiling things seemed to get stuck. I force reboot the HA and then I got this error.

In my case, I just need to uninstall esphome and re-install it. No need to reboot or restart HA. That fixes the error for me.

Happy I helped!

I’ve tried the solution a couple of times now, but I didn’t get it solved.
I tried serveral also some variances of rebooting and restarting.
What I could observe is that after install and reboot, the first build process in ESPHome cause a restart of HA. I don’t know why.
After that I get the

InvalidJSONFile: Could not load broken JSON: /data/cache/platformio/packages/tool-esptool/.piopm

error
Any ideas?
Issue was invented after updating to 2023.12.3

delete “/data/cache/platformio” folder. That fixes the error for me.

I didn’t have this path in my Terminal. So no cache folder under /data