Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid double naming of device tracker #278

Merged
merged 2 commits into from
Dec 19, 2024
Merged

Conversation

fredriklj
Copy link
Collaborator

It appears HA names the device tracker using device-name + attr_name. Setting attr_name to the vehicle.model_name, where no nick name has been assigned, means naming it twice with the same string:

Porsche Model Porsche Model

It appears HA names the device tracker using device-name + attr_name. Setting attr_name to the vehicle.model_name, where no nick name has been assigned, means naming it twice with the same string:

  Porsche Model Porsche Model
@CJNE
Copy link
Owner

CJNE commented Dec 18, 2024

Perhaps instead of removing the name altoghether, check if attr_name is set?

if vehicle.model_name:
        self._attr_name = vehicle.model_name

@fredriklj
Copy link
Collaborator Author

I believe vehicle.model_name always returns a string, and should return "modelName" (under all circumstances) which is part of what we call the base data. And "modelName" is the exact same string we set as device name, being inherited by the device tracker as well.

In your setup, what is the device tracker's name when self._attr_name is set to vehicle.model_name?

@fredriklj
Copy link
Collaborator Author

After having a closer look at it, I think the only situation where the device tracker would not be assigned the same string twice is when customName is set.

So checking if this is set and assigning an empty string if it is not should do it. Let's try this for now, to get the release out.

@fredriklj fredriklj merged commit 51ae5a6 into main Dec 19, 2024
2 of 3 checks passed
@fredriklj fredriklj deleted the device-tracker-naming branch December 19, 2024 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants