Error during renaming device in ESPHome

I want to rename my ESPHome device from ‘watermeter’ to ‘meterkast-controller’ but I get this error:

INFO Reading configuration /config/esphome/watermeter.yaml...
Updating /config/esphome/watermeter.yaml to /config/esphome/meterkast-controller.yaml

INFO Reading configuration /config/esphome/meterkast-controller.yaml...
ERROR Error while reading config: Invalid YAML syntax:

while parsing a block mapping
  in "/config/esphome/meterkast-controller.yaml", line 36, column 5:
      - platform: pulse_counter
        ^
expected <block end>, but found '<scalar>'
  in "/config/esphome/meterkast-controller.yaml", line 39, column 34:
        name: "meterkast-controller" pulse2"
                                     ^
Rename failed. Reverting changes.

I don’t understand what is wrong. When I validate the device everything is valid:

esphome:
  name: watermeter

esp8266:
  board: d1_mini

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "xxxxxxxxxxxxxxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Optional manual IP
  manual_ip:
    static_ip: ..................
    gateway: ...............
    subnet: .................
    dns1: .................

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Watermeter Fallback Hotspot"
    password: "xxxxxxxxxxxxxxxxxxxx"

captive_portal:

sensor:
# ⬇ watermeter ⬇ #
  - platform: pulse_counter
    pin: D2
    id: watermeter_pulse2
    name: "watermeter pulse2"
    state_class: measurement
    update_interval: 1s
    unit_of_measurement: L
    accuracy_decimals: 1
    filters:
      - multiply: 0.01342282
# ⬇ Totaal watermeter ⬇ #      
    total:
      id: sensor_pulse_meter_total2
      name: "watermeter Totaal2"
      icon: "mdi:cube-outline"
      unit_of_measurement: "m³"
      device_class: water
      state_class: total_increasing
      accuracy_decimals: 4
      filters:
      - multiply: 0.0008

  - platform: wifi_signal
    name: "Watermeter WiFi Signal"
    update_interval: 60s
  - platform: uptime
    name: "Watermeter Uptime"  
    
binary_sensor:
  - platform: gpio
    pin: D5
    name: "Voordeur"
    device_class: door    

  - platform: gpio
    pin: D6
    name: "Meterkastdeur"
    device_class: door    

It looks like that esphome is actually replacing all watermeter in your yaml with meterkast-controller. For some reason (bug?:bug:) it adds an extra " in your case causing the renaming to fail.

You could try to manually rename all name’s you have in your yaml before renaming the esphome node name:

Like

to

    name: "meterkast-controller pulse2"

and see if it makes a difference :bulb:

I had to much issues and decidet to remove the controller and add it again.