I have a number of sonoff devices configured in ESPHome. I am tring to work out the best naming convenstion to avoid duplication in the entity name.
if I have
esphome:
name: solder-fan
friendly_name: solder-fan
...
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode:
input: true
pullup: true
inverted: true
name: "solder fan"
on_press:
- switch.toggle: relay
switch:
- platform: gpio
name: "solder fan"
pin: GPIO12
id: relay
the entity name is switch.solder_fan_solder_fan
If I name the switch
switch:
- platform: gpio
name: "switch"
pin: GPIO12
id: relay
I get an entity of switch.solder_fan_switch
Is there any way of setting up the yaml so that I can have the entities
switch.solder_fan
and binary_sensor.solder_fan (for the button)
rather than having duplication somewhere in the name. I have searched but cannot find much on the recommended standard for the naming of ESPHone entities.
click on the card, rename the entity, or go to settings/devices-services/ entities … ( or click at the device there, then entities)
You can rename any way you want, and it’s highly a personal “opinion” , so use your imagination ( most likely you’ll have to rename alot again, when you find that your '“strategy” didn’t hold al the way
solder_fan might be “outstanding”, unless you get 2 or 3 solder_fan’s, 1 in garage, 1 in basement 1 “mobile” etc.
So it’s only you who can come up with the best naming , that works for you
PS: just make sure you can distinguish the both, if you want to call both for solder_fan ( friendly name )
I don’t think you are talking about ESPHome here - your answer doesn’t refer to any of the settings in the orignal post - I know I can rename entities through settings - that is not the question I asked, the question is how to avoid duplication in ESPHome entity names in the first place as the HA entity type is at the start followed by a . then the sensor name with the friendly_name appended.
1 Like
Yes you are right, i totally overlooked ESPHome, and thought it was “Naming” in common, i also now see that it’s posted under ESPHome, Topics i tend to “skip” reading as i dont currently have this integration/devices … My bad, apologies, hope you figure it out
… entity-type will always be at the start, regardless , naming a switch; Switch, is to me somehow irrelevant , I know it’s a Switch( hint: sensor_type ), so anyway you look at it, it’s totally up to what works for you.
As you are aware that you can name them whatever you want, it’s totally up to your imagination and fantasy, just dont type the same twice
it might not be what you are looking for but the statetegy with the same id for different types of components will fail you when you might need them in lambdas becuase the substitution macros can’t tell them apart: id(solder_fan) will clash having both id using the same identifier.
my solution is to prefix them or suffix them with an abreviated type:
- for a switch type: sw_fan or fan_sw
- for the gpio sensor: gpio_fan, sr_fan or fan_sr…
thanks - you are right that id should be different, with ESPHome id and name are different properties - it is the name that is the issue not the id - you’ll see that the switch has id: relay so the lambda id(relay) is fine… The ids need to be different. I was looking for recommendations of name to give a better naming convention than I currently have of switch.solder_fan_switch or switch.solder_fan_solder_fan.