Anyway to change service names that came from esphome created device?

Hello all,

Please see the screenshot below? I’m not sure what is going on but I will explain what I believe I know. The service “esphome.supermariolight_set_light_state” seems to be left in the system from a previously deleted esp32 build.

The “esphome.esphome_web_a13b8c_set_light_state” is the service name for what I would like to be named as what was in the previous paragraph.

Is there anyway to get all of this to correct itself? i.e. get one of the services deleted and somehow refresh the other to get it named properly?

Below is my current esp build yaml:

esphome:
  name: "supermariolight"
  friendly_name: supermariolight
  min_version: 2024.11.0
  name_add_mac_suffix: false

esp32:
  board: esp32dev
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  services:
    - service: set_light_state
      variables:
        state: string
      then:
        - lambda: |-
            if (state == "Device OFF") {
              id(button_counter) = 1;
            } else if (state == "Device ON") {
              id(button_counter) = 2;
            } else if (state == "Device PULSING") {
              id(button_counter) = 3;
            } else if (state == "REACTS TO SOUND") {
              id(button_counter) = 4;
            }
            // Update the sensor for Home Assistant
            id(button_counter_sensor).publish_state(id(button_counter));

# Allow Over-The-Air updates
ota:
- platform: esphome

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

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

captive_portal:


# Global variable to track the state
globals:
  - id: button_counter
    type: int
    restore_value: yes
    initial_value: '1'

# Define the GPIO output to simulate button presses
output:
  - platform: gpio
    pin: GPIO5  # Use GPIO5 to simulate the button press
    id: simulated_button
    inverted: True  # Inverts the signal, making it low by default


# Template switch to simulate button presses and track the counter
switch:
  - platform: template
    name: "Simulated Button"
    turn_on_action:
      - lambda: |-
          // Increment the counter
          id(button_counter) += 1;

          // Reset the counter after state 4
          if (id(button_counter) > 4) {
            id(button_counter) = 1;
          }

          // Log the state with meaningful names
          switch (id(button_counter)) {
            case 1:
              ESP_LOGD("main", "State 1: Device OFF");
              break;
            case 2:
              ESP_LOGD("main", "State 2: Device ON");
              break;
            case 3:
              ESP_LOGD("main", "State 3: Device PULSING");
              break;
            case 4:
              ESP_LOGD("main", "State 4: REACTS TO SOUND");
              break;
          }

          // Simulate the button press
          id(simulated_button).turn_on();
          delay(1000);  // Simulate the physical button press duration
          id(simulated_button).turn_off();

          // Update the sensor value after every press
          id(button_counter_sensor).publish_state(id(button_counter));

  # Virtual reset button to reset the counter
  - platform: template
    name: "Reset Button"
    turn_on_action:
      - lambda: |-
          // Reset the counter to 1
          id(button_counter) = 1;
          ESP_LOGD("main", "Button counter reset to 1");

          // Optionally, update the sensor state to reflect the reset
          id(button_counter_sensor).publish_state(id(button_counter));

# Expose the button_counter as a sensor to Home Assistant
sensor:
  - platform: template
    name: "Button Press Counter"
    id: button_counter_sensor
    lambda: |-
      return id(button_counter);
    on_value:
      then:
        - homeassistant.service:
            service: input_select.select_option
            data:
              entity_id: input_select.super_mario_light_state
              option: !lambda |-
                if (x == 1) {
                  return "Device OFF";
                } else if (x == 2) {
                  return "Device ON";
                } else if (x == 3) {
                  return "Device PULSING";
                } else if (x == 4) {
                  return "REACTS TO SOUND";
                } else {
                  return "Device OFF";
                }

A home assistant restart fixed this.