ESPHome encryption key is invalid

I also encoutered invalid encryption key. When I try to reflash through esphome flasher in windows
as I do it first time, it shows permission error. If I try “web.esphome.io”, it just keep connecting and Failed to initialize. How can I reflash it?

Physical serial connection.

Or entering the correct key in your yaml file.

Can you explain how to use serial connection? I am not sure how to do it.

What is your esp device.

My esp device is d1 mini.
I have found a instruction to use modern format and reflash from esp web tool.
Problem solved. Thanks!!

1 Like

But I still want to know how to use serial connection. Thanks.

D1 mini has a serial port. Plug it in to the computer running esphome. In the install dialog choose "plug into the computer running esphome dashboard "

I have try this method. But it just shows “Failed to initialize. Try resetting your device or holding the BOOT button while selecting your serial port until it starts preparing the installation.”

And have you done that?

Yes, I have solved through web esp tool. Just curious why it stock in the method you describe which is also I use at beginning.

Has anyone actually found a genuine fix for this issue, other than “try a different device”?

I’ve had a D1mini device with a weight sensor working for a long time, but changed the API (added encryption) after the update where it became advised/required?

I have tried everything in this thread - I’ve tried removing the encryption, and I’ve tried installing manually using legacy and modern methods. I have tried renaming the device, and I’ve been into the ESPHome folder and deleted everything relating to the device, to start from scratch.

Still, every single time, I view the logs, and it looks fine for a few seconds, then:

Connection error occurred: Invalid encryption key

I have 16 other ESPHome devices that all seem to be behaving properly.

Ignore me. Turns out I had a new device which I’d copied some stuff to, and inadvertently given it the same IP address, which it was hogging. So, it was trying to connect to that device, which had a different API key.
2 days that took to find :face_with_symbols_over_mouth:

1 Like

I wanted to remove api encryption key and also ran into this problem.

To fix this problem, use web.esphome.io using “Install” button to install your compiled firmware without api key.
This way the device is erased before flashing new firmware and no more api key invalid error.

1 Like

Just a FYI type of thing.

Had the same issue with the API key on just one node, although mine was actually still connecting to the web interface I included in the yaml.

I was Not able to flash via wifi Or cable as the D1 Mini was just flashing the blue onboard led trying to tell me I needed to varify it with the encryption key I lost when I loaded a prior version of home assistant from my backups (too long a story to get into).

Needless to say, I did the usual of going into the esphome interface, added a new node, called it by the same name, let it do just a basic install, then went into the yaml, removed the encryption completely, installed by downloading the bin file, then went onto the web page for the device and used the “OTA Upate” option, selected the file just created, selected update, and once that was successful, I used the code I made a backup of (I create a copy of all my nodes from “copy/paste” into text docs for future use), paste it into the yaml file, downloaded the bin again and uploaded again via the web page.

I now have a working D1 Mini that was just plain refusing to upload the bin file from virtually anywhere. I still wonder why the web page for the node allows for installations, and not esphome? :confused:

that was it
I copied the API key from my previous build with this board and it works

I removed the quotes from the api key and the error was gone.

1 Like

im having same bug today it was a brand new esp d1 mini not recycled so this issue is NOT solved

This also worked for me.

I edited the config for a new ESP32 I flashed, removed the quotes from the api key line, re-installed/flashed, and home assistant accepted the same transport encryption key.

3 Likes

Ha! After reading through everything else, I think that was the problem in my case.

I had:

airgradient-studio-a (20 characters)

but changed it to just:

ag-studio-a (11 characters)

And it started working with the exact same configuration otherwise. Not sure why, but I’ll keep my IDs a little shorter in the future :slight_smile:

think it might just have been already registered on HASS (same name at some point) and expecting that key. Changing the name makes it a new device with a new key ?

Maybe… just had this issue with a 2021 LED bulb i dug out my cupboard.