Don't prune blank entity names in overridden discovery data #523
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change
This change fixes a bug where entities using the default, blank-string entity names that are configured with
device_override_class
settings that modify their config fields would have their blank name fields removed from their MQTT discovery data, causing Home Assistant to name the entity "<device name> MQTT JSON Light" instead of the default "<device name>". I'm not really sure if this is the intended behavior of Home Assistant (i.e. this could be an HA bug, not ours), but we can preserve our desired naming by not pruning empty name fields from the MQTT discovery data.Additional information
Here is a simple
discovery_overrides
config that can reproduce the problem using Insteon Dimmers:With the above set as
device_override_class
for a dimmer named "Desk Lamp" Home Assistant produces the name "Desk Lamp MQTT JSON Light":This appears to be because the "name" field is removed from the MQTT discovery data:
With the proposed change, the blank "name" field is preserved, and the entity name stays set to "Desk Lamp" as it would without using the
device_override_class
.Checklist
If user exposed functionality or configuration variables are added/changed:
Confirmed no new flake8 errors, pylint errors, or code coverage gaps. All tests passing. Also, confirmed updated test (test_load_device_discovery_overrides) fails prior to applying fix: