Closed webash closed 1 year ago
Ugh, it appears 2023.8 of Home Assistant is changing the behaviour of this. I haven't yet updated, so I'll do that shortly and figure out whether this is still required. Probably isn't.
Yep; Home Assistant 2023.8 now finally configures the initial entity_id
of an entity linked (via identifier
or connection
) to a device with the device name included, so that you don't end up with binary_sensor.motion
as the entity_id
for an MQTT entity configured with only the entity_name
of motion
. Now it will finally configure that at as binary_sensor.device_name_motion
.
So this workaround that I added in this PR is no longer required for anyone on 2023.8 onwards.
I'll leave it open for now, but I'm guessing there isn't much point in adding it
I used to have the device_name prefixing the entity names, but had to change it due to the changes in naming standards (enforced in HA 2023.8). See #34. So, sorry, I'm going to have to reject this pull request as it is.
Since Home Assistant builds the
entity_id
from thename
property of an HA discovery packet, this ensuresentity_id
s are more specific than justapparent_power
.When displaying the entities, particularly on the device page, Home Assistant will omit the device name part of the string, because it will match the device name and that's how HA device-->entity hierarchy is maintained in the display names.
Having descriptive/specific
entity_id
is useful when only being able to glance at theentity_id
in a config. Similarly, the entity name containing the device name means that if you update the device name, all the entity (display) names of that device also update to match.Specific name and id make auto-complete/entity-only views clearer when trying to pick something like a
reactive_power
amongst a list of multiple of them; because now the entity ID or display name tell you which device without having to look it up separately.How will this affect existing users?
config.json
: Nothing The config itemdiscovery_entityname_prefix_with_devicename
will be null because it won't exist, so it won't update theentity_name
and it will stay the same as it was in previous versions.config.json
: Existing entities in HA will have the display name updated to include the device name, but theentity_id
will not update due to this potentially being a breaking change.All new users, or any existing users who configure the option AND delete their existing Home Assistant objects will see the intended behaviour, with all
entity_id
having the device id specified in it.Any existing users who want this change, but are not wishing to lose the history of objects already added can update the
entity_id
for each entity manually before or after adding"discovery_entityname_prefix_with_devicename": true
to their config file.