Skip to content

Commit

Permalink
auto delete bad_credentials issue on success
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasJoKuJonas committed Jan 8, 2024
1 parent af41b47 commit b7989c8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions custom_components/webuntis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def async_migrate_entry(hass, config_entry: ConfigEntry):
options = {**config_entry.options}

for option, default in DEFAULT_OPTIONS.items():
if not option in options:
if option not in options:
options[option] = default

config_entry.version = CONFIG_ENTRY_VERSION
Expand Down Expand Up @@ -164,6 +164,7 @@ def __init__(
self._loged_in = False
self._last_status_request_failed = False
self.updating = 0
self.issue = False

# Data provided by 3rd party library
self.school_year = None
Expand Down Expand Up @@ -385,6 +386,12 @@ def webuntis_login(self):
# _LOGGER.debug("Login successful")
self._loged_in = True
self.updating += 1

if self.issue:
_LOGGER.info("delete issue bad_credentials")
ir.async_delete_issue(self._hass, DOMAIN, "bad_credentials")
self.issue = False

return True
except OSError as error:
# Login error, set all properties to unknown.
Expand All @@ -406,6 +413,7 @@ def webuntis_login(self):
self._last_status_request_failed = True

if str(error) == "bad credentials":
self.issue = True
ir.async_create_issue(
self._hass,
DOMAIN,
Expand Down Expand Up @@ -720,7 +728,6 @@ def check_lesson(self, lesson, ignor_cancelled=False) -> bool:
except IndexError:
return False


for filter_description in self.filter_description:
if (
filter_description in lesson.lstext # Vertretungstext
Expand Down

0 comments on commit b7989c8

Please sign in to comment.