Skip to content

Commit

Permalink
Fixes #251 - HA 2024.11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
sander1988 committed Nov 11, 2024
1 parent c91ca1a commit 9ab9fa8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
28 changes: 11 additions & 17 deletions custom_components/indego/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from homeassistant.data_entry_flow import FlowResult
from homeassistant.helpers import selector
from homeassistant.helpers import config_entry_oauth2_flow
from homeassistant.components.application_credentials import ClientCredential, async_import_client_credential, DOMAIN as AC_DOMAIN, DATA_STORAGE as AC_DATA_STORAGE
from homeassistant.components.application_credentials import ClientCredential, async_import_client_credential
from homeassistant.helpers.aiohttp_client import async_get_clientsession
from homeassistant.config_entries import OptionsFlowWithConfigEntry, ConfigEntry
from homeassistant.core import callback
Expand Down Expand Up @@ -126,23 +126,17 @@ async def async_step_user(

# Create the OAuth application credentials entry in HA.
# No need to ask the user for input, settings are the same for everyone.
credentials = self.hass.data[AC_DOMAIN][AC_DATA_STORAGE].async_client_credentials(DOMAIN)
if DOMAIN not in credentials:
try:
_LOGGER.debug("Application credentials do NOT exist, creating...")
await async_import_client_credential(
self.hass,
DOMAIN,
ClientCredential(OAUTH2_CLIENT_ID, "", DOMAIN)
)
_LOGGER.debug("OK: Imported OAuth client credentials")

except Exception as exc:
_LOGGER.error("Failed to create application credentials! Reason: %s", str(exc))
raise
try:
await async_import_client_credential(
self.hass,
DOMAIN,
ClientCredential(OAUTH2_CLIENT_ID, "", DOMAIN)
)
_LOGGER.debug("OK: Imported OAuth client credentials (or are already exists)")

else:
_LOGGER.debug("Application credentials found, NOT creating")
except Exception as exc:
_LOGGER.error("Failed to create application credentials! Reason: %s", str(exc))
raise

# This will launch the HA OAuth (external webpage) opener.
return await super().async_step_pick_implementation(user_input)
Expand Down
2 changes: 1 addition & 1 deletion custom_components/indego/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"codeowners": ["@jm-73", "@eavanvalkenburg", "@sander1988"],
"requirements": ["pyIndego==3.2.2"],
"iot_class": "cloud_push",
"version": "5.7.6",
"version": "5.7.7",
"loggers": ["custom_components.indego", "pyIndego"]
}

0 comments on commit 9ab9fa8

Please sign in to comment.