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

Correct state attributes in group helper preview #99723

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion homeassistant/components/group/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ def ws_start_preview(
msg: dict[str, Any],
) -> None:
"""Generate a preview."""
entity_registry_entry: er.RegistryEntry | None = None
if msg["flow_type"] == "config_flow":
flow_status = hass.config_entries.flow.async_get(msg["flow_id"])
group_type = flow_status["step_id"]
Expand All @@ -370,12 +371,17 @@ def ws_start_preview(
name = validated["name"]
else:
flow_status = hass.config_entries.options.async_get(msg["flow_id"])
config_entry = hass.config_entries.async_get_entry(flow_status["handler"])
config_entry_id = flow_status["handler"]
config_entry = hass.config_entries.async_get_entry(config_entry_id)
if not config_entry:
raise HomeAssistantError
group_type = config_entry.options["group_type"]
name = config_entry.options["name"]
validated = PREVIEW_OPTIONS_SCHEMA[group_type](msg["user_input"])
entity_registry = er.async_get(hass)
entries = er.async_entries_for_config_entry(entity_registry, config_entry_id)
if entries:
entity_registry_entry = entries[0]

@callback
def async_preview_updated(state: str, attributes: Mapping[str, Any]) -> None:
Expand All @@ -388,6 +394,7 @@ def async_preview_updated(state: str, attributes: Mapping[str, Any]) -> None:

preview_entity = CREATE_PREVIEW_ENTITY[group_type](name, validated)
preview_entity.hass = hass
preview_entity.registry_entry = entity_registry_entry

connection.send_result(msg["id"])
connection.subscriptions[msg["id"]] = preview_entity.async_start_preview(
Expand Down