Can not figure out how HA named my sensors

I had Sen66-Sensor.yml in Esphome connected to HA server using USB. And it was added to HA. And HA was sending data to my LCD.yaml in Esphome over WiFi. Then I wanted to experiment with the same ESP32 with SEN66 to test WiFi instead of USB and added Sen66-air-Sensor.yml. Added to HA it was working OK, reporting data to dashboard (but not to LCD: sensor names were mismatch).
So i removed SE66_air_Sensor and Sen66-Sesor from HA. Modified Se66-Sensor.yml in esphome with WiFI components and uploaded. It works but sensor names are the same as they were with Sen66-air-Sensor.yml.
here is an example: running Se66_Sensor.yml but sensor name is sensor.sen66-air-sensor-sen66-temperature expected: sensor.sen66-sensor-sen66-temperature.

Here is my sen66-sensor.yaml

esphome:
  name: sen66-sensor
  friendly_name: SEN66 Sensor

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:

api:
  encryption:
    key: ""

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: SE66 Sensor Fallback Hotspot
    password: ""    
#######################################


i2c:
  sda: GPIO21
  scl: GPIO22
  scan: true

sensor:
  - platform: sen6x
    id: my_sen66
    type: SEN66
    co2:
      name: "sen66 co2 level"             
      id: local_co2
    pm_2_5:
      name: "sen66 pm25 fine dust"       
      id: local_pm25
    voc:
      name: "sen66 voc index"             
      id: local_voc
    nox:
      name: "sen66 nox index"             
      id: local_nox
    temperature:
      name: "sen66 temperature"           
      id: local_temp
    humidity:
      name: "sen66 humidity"              
      id: local_hum

  # the warmup timer
  - platform: uptime
    id: sen6x_uptime
    internal: true
    update_interval: 10s

# status scale locally on the ESP32 chip
text_sensor:
  - platform: template
    name: "sen66 sensor health scale"
    id: sen66_diagnostic_scale
    lambda: |-
      // 1. WARMUP
      if (id(sen6x_uptime).state < 60.0) {
        return {"Initializing"};
      }

      // 2. NOT CONNECTED / BUS FAILURE
      if (std::isnan(id(local_temp).state)) {
        return {"Not Connected"};
      }

      // 3.SENSOR SUBSYSTEM DIAGNOSTICS
      if (std::isnan(id(local_pm25).state)) {
        return {"Bad Laser/Fan"};
      }
      
      if (std::isnan(id(local_co2).state)) {
        return {"Bad CO2 Sensor"};
      }

      if (std::isnan(id(local_voc).state) || std::isnan(id(local_nox).state)) {
        return {"Bad MOX Gas Element"};
      }

      // 4. ALL ENGINES HEALTHY
      return {"Good"};
    update_interval: 10s

# USB console
interval:
  - interval: 5s
    then:
      - lambda: |-
          std::string current_status = id(sen66_diagnostic_scale).state;
          if (current_status == "Good") {
            ESP_LOGI("sen66", "Status: %s | CO2: %.0f ppm | PM2.5: %.1f", current_status.c_str(), id(local_co2).state, id(local_pm25).state);
          } else {
            ESP_LOGE("sen66", "Status Alert: %s", current_status.c_str());
          }

Why would changing the connection method change the sensor name?

Delete the device from Home Assistant and change the esp board name. Re-upload the config. Re-add to home assistant.

Or just change the sensor name in the esp yaml file and re-upload the config.

Also I was not aware this was possible:

My guess is that strobes either renamed his .yaml file, or created a copy with new name but accessing the same physical device - and so the entity names in HA get out of sync with the entity_IDs in HA. I have had problems from doing this myself, even last week.

@strobes I believe we understand what you mean, but in future it would be helpful if you could be a bit more precise when referring to Home Assistant (HA), the ESPHome Device Builder (an app which runs on the HA computer), and the device running the ESPHome-generated firmware. Also note that the difference between a dash (-) and underline (_) is important.

Home Assistant generates entity names in a format of sensor., so “sensor.sen66-air-sensor-sen66-temperature” is a sensor from the “sen66_air_sensor” device with name of “sen66_temperature”.

I have found that in HA, changing the device name does not change the HA entity_IDs - and after a while it can get very confusing for me with some entities with the old device name and some with the new device name. I think this is what has happened to you.

Looking in HA > Devices & Services > ESPHome (not the ESPHome Device Builder) you have listed your device listed, looking something like


Up in the top right corner is the pencil icon which lets you change the device name in HA (but doesn’t automagically change it in ESPHome Device Builder or your YAML file - another possible place for confusion) and its Area. Next to the pencil is a menu (shown by 3 vertical dots) which includes “Recreate entity IDs”.
If you select “Recreate entity IDs” you will see a pop-up window which will probably tell you that some entity IDs will be renamed, and that some entity IDs will not be renamed.

Clicking on either will open the list so you can see them

In my example on the second line you will see
select.lva_b827eb86d7dc_assistant select.study_lva_3b_assistant
indicating that the “select” type entity named “assistant” was registered before I changed the device name from “lva-b827eb86d7dc” to “lva-3b”. If I click the [Update] button this entity will be renamed to the new device name “lva-3b” and have the area (“study”) also added to the entity_ID.

I THINK this is what you want to do - but check it out first.

I did all you mentioned: removed both devices from HA dashboard, renamed yaml, reloaded and sensors still have “air” in the name. So I had to manually change entities. to match sensor names that my LCD expects.

From memory, I think it was like this. Also to mention, I had to add it manually to HA devices by selecting UART. Just to mention - it was tested without SEB66 attached, but logs and HA dashboard was listing correct sensors without actual data. esphome:

  name: sen66-sensor

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:
  baud_rate: 115200
  hardware_uart: UART0 ----- not sure about this line

Yes, that is what I did. And reading my post over I see where I was not not specific and may caused confusion. Thank you. Let me read your post in details so I can follow later. Yes entities naming can get confusing fast without good understanding how HA generates these.

You might wanna wait. Tomorrow’s HA release has some improvements & control over how your devices get named when first adding them to HA.

Not sure whether this also applies to esphome devices. It should, but you’ll probably have to remove & readd them