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

Fix Configure of existing Places Sensor #317

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ repos:
rev: v2.2.4
hooks:
- id: codespell
args: [--skip,"*.json"]
additional_dependencies:
- tomli
- repo: https://github.com/astral-sh/ruff-pre-commit
Expand All @@ -29,3 +30,11 @@ repos:
args: [--fix]
# Run the formatter.
- id: ruff-format
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
autofix_prs: true
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: []
submodules: false
10 changes: 3 additions & 7 deletions custom_components/places/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,16 +269,12 @@ def async_get_options_flow(
config_entry: ConfigEntry,
) -> PlacesOptionsFlowHandler:
"""Options callback for Places."""
return PlacesOptionsFlowHandler(config_entry)
return PlacesOptionsFlowHandler()


class PlacesOptionsFlowHandler(OptionsFlow):
"""Config flow options for Places. Does not actually store these into Options but updates the Config instead."""

def __init__(self, entry: ConfigEntry) -> None:
"""Initialize Places options flow."""
self.config_entry = entry

async def async_step_init(
self, user_input: MutableMapping[str, Any] | None = None
) -> ConfigFlowResult:
Expand All @@ -295,10 +291,10 @@ async def async_step_init(
user_input.pop(m)
# _LOGGER.debug(f"[Options Update] updated config: {user_input}")

self.hass.async_update_entry(
self.hass.config_entries.async_update_entry(
self.config_entry, data=user_input, options=self.config_entry.options
)
await self.hass.async_reload(self.config_entry.entry_id)
await self.hass.config_entries.async_reload(self.config_entry.entry_id)
return self.async_create_entry(title="", data={})

# Include the current entity in the list as well. Although it may still fail in validation checking.
Expand Down
Loading