Error when calling esphome cli command "upload"

Hi,
after not updating esphome for a while (last version used is 2022.10.1) I updated to 2023.10.4.
I am using virtual environments on macOS.

After setup new environment for esphome 2023.10.4 I can compile my yaml code. Most esphome commands (clean, compile, logs, mqtt-clean) are working.

But when I try to upload (OTA) the new binary to my device I get the following error:

INFO ESPHome 2023.10.4
INFO Reading configuration wz-aq-vindriktning.yaml...
Traceback (most recent call last):
  File "/Users/ulrich/devkits/esphome_2023_10_4/bin/esphome", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/Users/ulrich/devkits/esphome_2023_10_4/lib/python3.12/site-packages/esphome/__main__.py", line 1036, in main
    return run_esphome(sys.argv)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ulrich/devkits/esphome_2023_10_4/lib/python3.12/site-packages/esphome/__main__.py", line 1023, in run_esphome
    rc = POST_CONFIG_ACTIONS[args.command](args, config)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ulrich/devkits/esphome_2023_10_4/lib/python3.12/site-packages/esphome/__main__.py", line 425, in command_upload
    exit_code = upload_program(config, args, port)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/ulrich/devkits/esphome_2023_10_4/lib/python3.12/site-packages/esphome/__main__.py", line 331, in upload_program
    config, args.username, args.password, args.client_id
            ^^^^^^^^^^^^^
AttributeError: 'Namespace' object has no attribute 'username'

My device uses MQTT. Home Assistant API is disabled. mDNS is also disabled.

Switching to my 2022.10.1 esphome environment I can upload the binary compiled by 2023.10.4 to my device. So maybe something is missing inside my yaml?

What could I do, to upload my binary using the esphome 2023.10.4 CLI?

I think there have been a change in the authentication for uploading.
Check the changelogs on the ESPHome page.

Thanks. Tried to find if something changed for the OTA component. But didn’t find relevant changes.

Well, it complain about a missing username

Yes. Bot don’t know where I have to start searching. Could narrow down the error to esphome 2023.6.1. Thats the first version where this error occurs.
But there is only one none breaking change inside mqtt. Could not find other relevant changes?
To get rid of side effects or incompatible versions I used docker images for my testings.

Maybe someone has an idea? Any help is appreciated.

It is not related to MQTT, I think.

Try to post your YAML.

Here is my yaml.

substitutions:
  node_name: wz-aq-vindriktning
  id_prefix: wz_aq_vindriktning
  name_prefix: wz_aq_vindriktning
  psm: HIGH
  node_comment: "IKEA Vindriktning Air Quality Sensor."


wifi:
  ssid: "H3N1"
  password: !secret h3n1_passwd
  domain: .XXXX.XXXXXX.de
  power_save_mode: ${psm}

  ap:
    ssid: ${node_name} fallback
    password: !secret fallback_ap_passwd

mdns:
  disabled: true

web_server:
  port: 80
  version: 1
  auth:
    username: XXXXXXXX
    password: !secret web_passwd

mqtt:
  broker: XXXX.XXXX.XXXXXX.de
  username: XXXXXX
  password: !secret mqtt_passwd
  discovery: true
  topic_prefix: esphome/${id_prefix}
  reboot_timeout: 60 min

time:
  - platform: sntp
    id: sntp_time
    servers: XXXX.XXXX.XXXXXX.de
    timezone: Europe/Berlin

ota:
  password: !secret ota_passwd

captive_portal:

switch:
  - platform: safe_mode
    id: ${id_prefix}_safe_restart
    name: ${name_prefix} Safe Restart
    
  - platform: restart
    id: ${id_prefix}_restart
    name: ${name_prefix} Restart


esphome:
  name: ${node_name}
  comment: ${node_comment}

esp8266:
  board: esp01_1m
  
logger:
  level: INFO
  baud_rate: 0

uart:
  rx_pin: GPIO3
  baud_rate: 9600

sensor:
  - platform: pm1006
    pm_2_5:
      name: pm25
      accuracy_decimals: 2
      filters:
        - or:
          - delta: 3
          - heartbeat: 10s
        - sliding_window_moving_average:
            window_size: 20
            send_every: 10
            send_first_at: 10

Your YAML seems fine to me and the fact that you seem to be able to compile it also suggest so.
It is the upload that is the issue.
I can’t see what should cause it, so you need someone with an understanding of the ESPHome code and not the YAML parsing.

I can suggest that you add more to you secret file, so things like usernames and maybe also URL to services gets included. I can see you have them changed and they would likely be the same over multiple devices, so one spot to change them all might be nice, if you need to change them in the future. :wink:

You are right. Only upload command is failing. All other cli commands works fine.

Tanks for your suggestions. Next week I will do some tests with a complete new configuration and module.
Maybe I could than narrow down the issue why upload is failing.

Also created an issue in esphome GitHub. Maybe someone over there could help me.

There is an error introduced with esphome 2023.6.1. upload fails because the necessary MQTT params are not read from the yaml configuration.

Thanks for making a comment about it. It will help the next one with the problem that finds this thread.
Could you post a link to the Issue on Github, if you know it? :slight_smile:

Link to issue

Local fix is working. Will try to create PR tomorrow.