There has been some major discussion and disagreement about a recent push to changing how entities are named in Home Assistant.
I have not been able to find a discussion thread that brings both sides of this argument together to try and find a solution or common ground.
It seems like the HA developers have decided to side with one group, and tensions are high.
The purpose of this thread:
This is not a place to paint each other as “wrong” or “stupid”. It is not a place to judge how one person sets up their home vs another. The spirit of Home Assistant has always been open source and open choice with the goal as to allowing people to setup their smart home how they seem fit.
This recent change or direction I feel limits that.
The discussion topic:
We are here to discuss “What is a device?”, “What is an entity?” and “How do they relate to one another?”
This is the point of contention, there are differing viewpoints on this. I feel like if we can agree on definitions for these things than we can possibly come to some kind of agreement.
The problem is, there is no “one size fits all” solution to this. Devices vary wildly, and I feel that trying to come up with a cookie cutter method is great for a “default” but not a “requirement”.
Lets get into it, here is how I answer those questions.
- What is a Device?
- To me a device is the physical object that I installed or place in or on my home that interacts with Home Assistant.
- What is an entity?
- An entity, is something created by a device for the purpose of giving me information about something around my home, or control over something in my home.
- An entity falls into 3 major categories:
- Something that tells me about the device or environment around the device (sensor).
- Something that directly controls an aspect or function of the device itself. Such as a power button that turns the device that created it on or off.
- Something that controls an aspect or something other than the device that created it. Usually represents a part of the device designed to control or manipulate another object that is not part of the device itself.
- How do they relate to each other?
- This depends on the purpose for the entity.
- If the entity is there to tell me about the device that created it, or give information about the environment around the device. Then the entity belongs to that device. Such as a temperature reading.
- If the entity is something that directly controls a part of the device itself, such as a “oscilation” setting on a smart fan which tells the smart fan to oscilate or not, then that entity belongs to the device.
- If the entity is something that is designed to interact with another object or device, that is not a part of the device that created it, then that entity represents or belongs to the device it controls and not the device that created it.
Some Examples
-
A Physical Switch, that exists on the wall in the living room. When flipped it turns on the ceiling fan in the living room.
- Device name: “Living Room Fan Switch”
- Reasoning: I have 2 fans in my house. One in the living room, and one in the bedroom. Device names must be unique in Home Assistant. So, I can’t name both devices “Fan”. So I add the area name to the device name. (which is also as redundant of the device name showing up in the name of the sensor, yet this isn’t a point of contention, only the device name for some reason)
- Area: “Living Room”
- Entities:
- Temperature sensor:
- Entity Name: “Temperature”
- Reasoning: This is the temperature of the physical switch.
- Friendly Name: “Living Room Fan Switch Temperature”
- Entity_id: sensor.living_room_fan_switch_temperature
- Reasoning: The sensor gives data about the temperature of the physical switch device, so naming it after the device makes sense.
- Switch Entity:
- Entity Name/Friendly Name: “Living Room Fan”
- Entity_id: switch.living_room_fan
- Reasoning: The entity doesn’t control the switch itself, it controls the fan. (Setting the “Show as” setting to “Fan” simply creates another entity with the id of “fan.living_room_fan”.) If I name the entity this, then voice assistants already understand what I mean when I say “turn on the living room fan”. No alias is necessary. And if I set the “Show as” to fan, and allow the “fan.” entity to be created then “Turn on all living room fans” will also work. It just works, as is, by naming one entity. With the current plan, this entity would be forced to be called “Living Room Fan Switch” (if the entity_name was set to “none” and it adopted the name of the device that created it.) This… does not make sense when controlling devices with voice assitants. It also doesn’t make sense on dashboards. And if “Show as” is changed to “Fan” it would still be called “fan.living_room_fan_switch” which is also wrong since … I want it to be shown as a “Fan” not a switch. The argument could also be made that “Switch” in the name is redundant. “switch.living_room_fan_switch” could very easily be shortened to “switch.living_room_fan” so the name “Living Room Fam” makes perfect sense.
- Entity Name: “Temperature”
- Temperature sensor:
- Device name: “Living Room Fan Switch”
-
A contact sensor on the left window, in the living room.
- Device Name: “Living Room Left Window”
- Reasoning: This is what the device represents in my house. All the entities would automatically be named something that makes sense by the default naming convention. The argument could be made that this should be called “Living Room Left Window Sensor”. But again, “sensor.living_room_left_window_sensor” feels redundant. However, this point doesn’t really matter since this is the device name, and we are really discussing how the device name relates to the entity name, and what if any affect it should have on entities.
- Area: Living Room
- Entities:
- Binary Sensor / Contact Sensor:
- Entity Name: None integration doesn’t set one up.
- Reasoning: This entity represents the core function of the device, and thus should get the same exact name of the device.
- Friendly Name: Living Room Left Window
- Entity ID: binary_sensor.living_room_left_window
- Entity Name: None integration doesn’t set one up.
- Binary Sensor / Tamper Sensor:
- Entity Name: “Tamper”
- Reasoning: This entity represents another aspect of the device.
- Friendly Name: Living Room Left Window Tamper
- Entity ID: binary_sensor.living_room_left_window_tamper
- Entity Name: “Tamper”
- Binary Sensor / Contact Sensor:
- Device Name: “Living Room Left Window”
Some points of commonality.
As you can see, because of each device/entity needing to have a unique name, the area ends up in the name already. So it makes sense that area be the first part of a name. (However “Left Living Room Window” seems just as valid as “Living Room Left Window”).
It makes more sense to describe an entity by it’s area rather than it’s device in some cases, especially cases where the entity is in a different area than the device that provides it.
For me an entity name is: “Area Name + Device the entity controls/gives info on + Entity Name”
So whether or not the name of the device providing the entity should be in the name of the entity entirely depends on the entity itself, and the purpose/function of the device.
Perhaps entities really need another attribute: “device_contained: True/False”.
A “Device contained” entity is an entity that controls or gives info about the device that provides it. An entity that is “Not device contained” controls another object or device.
Device Contained entities should have the device name, in their name. It makes sense because they are a part of the device. However a “not device contained” entity should be named after the Object/Device it actually controls.
A “Device Contained” or similar attribute solves the issue of entity naming without the complication of having to add “sub devices”.