Skip to content

Commit

Permalink
Fix Configure of existing Places Sensor (#317)
Browse files Browse the repository at this point in the history
  • Loading branch information
Snuffy2 authored Jan 16, 2025
1 parent 3a603f3 commit 61db53f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
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

0 comments on commit 61db53f

Please sign in to comment.