Skip to content

Commit

Permalink
fix accounts optionsflow saving None value
Browse files Browse the repository at this point in the history
  • Loading branch information
pantherale0 committed Sep 20, 2023
1 parent 94b0459 commit 13bb876
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 2 additions & 6 deletions custom_components/family_safety/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ async def async_step_applications(
)

default_tracked_applications = []
tracked_applications = self.config_entry.data.get("tracked_applications", [])
if self.config_entry.options:
tracked_applications = self.config_entry.options.get("tracked_applications", [])
tracked_applications = self._get_config_entry("tracked_applications")
if tracked_applications is None:
tracked_applications = []
for app in tracked_applications:
Expand Down Expand Up @@ -240,11 +238,9 @@ async def async_step_accounts(
)

default_tracked_accounts = []
tracked_accounts = self.config_entry.data.get("accounts", [])
tracked_accounts = self._get_config_entry("accounts")
if tracked_accounts is None:
tracked_accounts = []
if self.config_entry.options:
tracked_accounts = self.config_entry.options.get("accounts", [])
for account in tracked_accounts:
try:
acc = self.family_safety.get_account(account)
Expand Down
3 changes: 2 additions & 1 deletion custom_components/family_safety/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ async def async_setup_entry(
accounts: list[Account] = hass.data[DOMAIN][config_entry.entry_id].api.accounts
entities = []
for account in accounts:
if (account.user_id in config_entry.options.get("accounts", [])) or (
if (config_entry.options.get("accounts", None) is None) or (
account.user_id in config_entry.options.get("accounts", [])) or (
len(config_entry.options.get("accounts", []))==0
):
for platform in DEFAULT_OVERRIDE_ENTITIES:
Expand Down

0 comments on commit 13bb876

Please sign in to comment.