-
-
Notifications
You must be signed in to change notification settings - Fork 38.3k
Extend WS API result when enabling an entity #42667
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
64947ba
cecfe04
1d54b98
515c2c1
f7982d7
b461710
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| """HTTP views to interact with the entity registry.""" | ||
| import voluptuous as vol | ||
|
|
||
| from homeassistant import config_entries | ||
| from homeassistant.components import websocket_api | ||
| from homeassistant.components.websocket_api.const import ERR_NOT_FOUND | ||
| from homeassistant.components.websocket_api.decorators import ( | ||
|
|
@@ -114,6 +115,15 @@ async def websocket_update_entity(hass, connection, msg): | |
| websocket_api.error_message(msg["id"], "invalid_info", str(err)) | ||
| ) | ||
| else: | ||
| result = websocket_api.result_message(msg["id"], _entry_ext_dict(entry)) | ||
| if "disabled_by" in changes and changes["disabled_by"] is None: | ||
| config_entry = hass.config_entries.async_get_entry(entry.config_entry_id) | ||
| if entry and not config_entry.supports_unload: | ||
| result["result"]["requires_restart"] = True | ||
| else: | ||
| result["result"][ | ||
| "reload_delay" | ||
| ] = config_entries.RELOAD_AFTER_UPDATE_DELAY | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe the WS response should be reorganized such that the entity_entry is moved to a sub dict: result = websocket_api.result_message(msg["id"], {"entity_entry":_entry_ext_dict(entry)})
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, better move the entry to a dict to not conflate keys.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, fixed. |
||
| connection.send_message( | ||
| websocket_api.result_message(msg["id"], _entry_ext_dict(entry)) | ||
| ) | ||
|
|
||
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.
Let's drop this
elseand instead do areturninside theexcept.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.
Fixed.