-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Default name for Tapo P304M that can't be named #141069
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
Conversation
Hey there @rytilahti, @bdraco, @sdb9696, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
# The P304M is a power strip with no alias. During setup in the Tapo app the parent | ||
# device cannot be named, only the individual outlets can have aliases so we need to | ||
# return a valid one for the parent to avoid "unnamed_p304m" in the entity id. | ||
if device.model == "P304M": | ||
return "Tapo P304M" |
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.
Hmm, this makes me wonder, should the device model be the final fallback in general?
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.
Probably yes, combined with a shortened device id, or a mac. I'd prefer to have that implemented upstream, so feel free to create a PR to python-kasa project.
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.
@frenck I agree it's not ideal, I just wanted to start a conversation to understand where the solution should live. @rytilahti I'm not familiar with that API. Thank you both for the feedback!
As mentioned in this PR's description, it would be best to fix both both the entity ids and the device name. The latter is set to "None P304M" automatically. It can easily be changed in the UI, but "Tapo P304M" sounds like a better default name.
Could you point to where it's best to make the change to fix both problems on the python-kasa
project?
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.
https://github.com/python-kasa/python-kasa/blob/579fd5aa2add10a2f3cc3ce21cb6a006e11de318/kasa/smart/smartdevice.py#L599 this is where the none is coming, but I cannot recall why it was marked as optional. Maybe to allow downstream projects to decide how to handle naming?
I'm not sure if we want to add the brand name to the alias, but that would be the place to modify the name (and indirectly, entity ids which are based on that) that is used by homeassistant and the kasa cli tool, too.
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.
Thanks for the direction! I created a PR with a proposed solution, you can read the short description and we can discuss further if necessary.
EDIT: I'll close this PR as soon as we're done on python-kasa.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Proposed change
Tapo P304M is a power strip with 4 sockets that can be controlled individually.
Since the Tapo P304M can't be named in the Tapo app, entities are created with
unnamed_p304m_...
as id prefix. Only the four sockets can be renamed (default is "Tapo Plug 1" with numbers 1 to 4). Renaming 64 entity ids by hand is painful, so a default name like "Tapo P304M" would be nice. It would also result in id prefixes beingtapo_p304m_...
.This PR is a draft to explore the possibilities to achieve the desired result.
Currently the only change is inside the
get_device_name
method. If the device has noalias
andparent
is falsy, then I added an additional check fordevice.model == "P304M"
to return a default"Tapo P304M"
.Critical points I'm looking for feedback on:
tapo_p304m_...
now. However I'm not sure if this is the right chunk of code to accomplish this. Maybe it should be done wherever thisdevice_name
is turned to snake_case and used to assemble the entity ids.This aims to be a non-breaking fix.
Type of change
Additional information
Checklist
ruff format 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
.To help with the load of incoming pull requests: