-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
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
Explicitly set entity name for VenstarSensor #102158
Explicitly set entity name for VenstarSensor #102158
Conversation
Hey there @garbled1, @jhollowe, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all good. WHy do you want to update the _attr_name to None? It will cause multiple names on the device name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the right way to solve this issue. This will rename every sensor to the device name, causing sensor.{device_name}
and sensor.{device_name}_1
. This means one of the entities created doesn't have a translation key or device class (or name)
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
I just checked the code, and every sensor does have a name, so I am curious where this message comes from |
So to explain it more, this message only pops up when the entity has @property
def name(self):
"""Return the name of the device."""
return self.entity_description.name_fn(self.sensor_name) This part of the code makes sure the code always returns a name. This function never seems to return I am guessing you can set this integration up in a development environment. Can you maybe give it a shot to change that piece of code to this? @property
def name(self):
"""Return the name of the device."""
name = self.entity_description.name_fn(self.sensor_name)
print(name)
return name This would print out the name of the sensor before being returned. If I have to believe the code, this should never print |
FWIW, the proposed change did make the warning go away for me, did not generate any new errors, and didn't appear to affect functionality at all. I changed the diagnostic code to use logging instead of print() (and reverted my change). Here's what I get on startup...
|
Heh, this doesn't make sense |
Right, I looked it up and I might found something. Can you try |
That seems to make everything happy. If I don't hear any counter arguments, I'l update the commit in a bit. |
I copied this from Unifi, so I would say go for it |
35b0cb8
to
8ed5b8d
Compare
Set entity name using _attr_name instead of a name property, to avoid warnings about name being implicitly set to None.
8ed5b8d
to
3be0e64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you put this ready for review I will merge this
Proposed change
Address:
[homeassistant.helpers.entity] Entity None (<class 'homeassistant.components.venstar.sensor.VenstarSensor'>) is implicitly using device name by not setting its name. Instead, the name should be set to None, please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+venstar%22
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: