You don’t need substitutions for friendly name any more
If you have this (or similar) in your config:
esphome:
name: air-filter
friendly_name: Air Purifier
comment: ESP32 DEV BOARD
then esphome will now name all your entities NAME entity, ie:
fan:
- platform: speed
output: fan_output
name: Fan
speed_count: 10
will create entity Air Purifier Fan, fan.air_purifier_fan
Also, If you have a friendly_name set for your device and you want the entity to use that name, you can set name: None. This would create a fan entity called Air Purifier
This is not the complete YAML of that device. Where are the board codes and all that?
The name that will be used by ESPHome for that device comes from the name entity under the esphome: entry.
The documentation says this:
Here you specify some core information that ESPHome needs to create firmwares. Most importantly, this is the section of the configuration where you specify the name of the node.
So for your case, you’d need to set the config entries, if you don’t want ESPHome to name your device. And that is what’s happening here: you didn’t specify a name for that device. Not the device_name, not the friendly_name, just the name for your device. If this isn’t set, ESPHome does generate a name.
needs this to be correct and the naming will be like you want it:
substitutions:
device_name: freds-chair
friendly_name: freds_chair
esphome:
name: freds_chair #or whatever you name it
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
#fast_connect: true
To get there, I’d suggest copying the YAML from that device, delete it in ESPHome and HA-ESP-integration and set it up new in ESPHome, where you can re-add the YAML code and add the name.
Btw. I’m surprised this is working. Normally you need to define the board for ESPHome to generate a firmware…?
Fair question.
Since I am almost always using an ESP8266 device with a lot of the same code at the top of the device file, I have moved the repetitive stuff to packages (common files). It makes my device files smaller.
Yes, there is a name: component in one of the common files.
esphome:
name: ${device_name}
Below are the whole device YAML file, and the common files.
# This is the chair servo for the 2023 Halloween props.
# PWM Output is on GPIO2
# A button can be added to GPIO0
substitutions:
device_name: freds-chair
friendly_name: freds_chair
packages:
wifi: !include common/wifi.yaml
device_base: !include common/esp8266.yaml
######################################################
output:
- platform: esp8266_pwm
id: pwm_output
pin: 2
frequency: 50 Hz
servo:
- id: servo_signal
output: pwm_output
restore: true
number:
- platform: template
name: ${friendly_name} servo control
min_value: -100
max_value: 100
step: 1
set_action:
then:
- servo.write:
id: servo_signal
level: !lambda 'return x / 100.0;'
button:
- platform: template
name: ${friendly_name} zero
icon: "mdi:liquid-spot"
on_press:
then:
- script.execute: move_to_zero
- platform: template
name: ${friendly_name} look left
icon: "mdi:liquid-spot"
on_press:
then:
- script.execute: look_left
- platform: template
name: ${friendly_name} look right
icon: "mdi:liquid-spot"
on_press:
then:
- script.execute: look_right
#Pressing the button on GPIO0 returns the servo to zero.
#binary_sensor:
# - platform: gpio
# name: ${friendly_name} action_button
# pin:
# number: 0
# mode: input_pullup
# inverted: True
# id: button_fire
# on_press:
# then:
# - script.execute: move_to_zero
script:
- id: move_to_zero
then:
- servo.write:
id: servo_signal
level: 0%
- id: look_left
then:
- servo.write:
id: servo_signal
level: 100%
- id: look_right
then:
- servo.write:
id: servo_signal
level: -100%
esp8266.yaml common file:
################################################
#esp8266
#
#Useage:
#packages:
# wifi: !include common/wifi.yaml
# device_base: !include common/esp8266.yaml
#
#In the project file, you can override the default board type.
#For example:
#esp8266:
# board: esp01_1m #Sonoff Basic and Mini (DEFAULT)
# board: d1_mini #Wemos D1 Mini
# board: nodemcuv2 #NodeMCU
#
################################################
esphome:
name: ${device_name}
esp8266:
board: esp01_1m
framework:
version: recommended
# Logger level "debug" is needed to get 1-Wire addresses, like the ds18b20.
logger:
level: DEBUG
api:
ota:
safe_mode: True
You provided the ID and the FRIENDLY NAME, you did not provide the entity_id that is passed to HA, therefore it picked up the defaults for the entity ID, but your friendly names appear to be as you would expect. The ID you supplied is the ESPHome reference ID that you can use in other code.
I believe I said that correctly, @tom_l please correct me if I did not represent the issue and solution properly.
I’ve been using these packages on more than a dozen devices and never had a name issue.
But back to the earlier question- can I safely delete the device from the ESPHome control panel then delete all of the freds-chair.* files and start over?
That’s unfortunate, I had hoped it might be just that.
What you’re doing should in theory work… And I assume you already checked, that both “package” files are available? Sorry, but I have no idea what could be the reason.
You should enable the debug logs in ESPHome for the device and run an install. Maybe that brings some insight. I would speculate, that if there is some “misconfiguration” with the name, eg. something with the 8266.yaml file is wrong, that ESPHome just logs a warning and generates the name. Worth a try to check these logs.
That brings us to your next question. Yes, it is safe to delete the files. I read your other topic, and would as well delete the freds-chair files. Just start fresh, and don’t forget to delete all entities upfront in HA! Maybe try to use “fresh” naming like fredschair without a hyphen or something like that.