-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
Allow storing device options in DeviceEntry #59668
Conversation
As pointed out by @mib1185 on Discord, there is a problem with this approach. Devices are potentially shared across integrations, thus options can conflict. Does this need namespacing or something? This gets ugly fast probably. Another option would be adding methods for getting/setting options, and making domain mandatory in these calls. |
It would be great for #58921
I'm curious about how does this works. I thought that each device was bound to just one integration. |
See the developer docs here https://developers.home-assistant.io/docs/device_registry_index especial the |
I like having it inside the entry. If it's just calls on integration level, it would still need to figure out a storage location. |
@elupus you mean config entry? If so, a config entry is not device level, as a config entry can provide multiple device. If not, I think I don't understand your comment. |
Please note I made this PR as a draft as an example. I have another option ready and I actually believe this PR is a wrong approach |
No i meant the entry for the device in the device registry. I commented on your alternate approach of setters/getters. I think i thought about it backwards. I thought you intended for a integration level callback (like async_setup/restore state). But i realize that doesn't make much sense. So setters getters in device registry could make sense. Mainly to avoid clobbering other domains settings by misstake. Could simplify code too, since you would not need an instance of the device to get device settings, just it's identifiers. |
I think I have an idea on how to make this easier to use. will try to work an example out. |
2b07378
to
4c1f5e1
Compare
Proposed change
This is a meta/suggestion PR at this point.
And is inspired by #58757 (review) and earlier discussions.
This change adds a fairly simple
options
dictionary to theDeviceEntry
, in which we would allow integrations to store additional device options. These can be used for adjusting the behavior of a specific device, or, expose entities that control these parameters to adjust behavior.This is very much in line with the
ConfigEntry
options (except for that one, we have a flow, in this case, we can leave it up to the integration).This can be useful for things like:
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
.The integration reached or maintains the following Integration Quality Scale:
To help with the load of incoming pull requests: