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

Convert yale to use oauth #123806

Merged
merged 70 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
724ef4e
Convert yale to use oauth
bdraco Aug 13, 2024
a0fb23f
update
bdraco Aug 13, 2024
505f55a
tweak
bdraco Aug 13, 2024
a157323
fixes
bdraco Aug 13, 2024
f906b62
token
bdraco Aug 13, 2024
3033c8a
fix august import
bdraco Aug 13, 2024
4e387c8
fix august import
bdraco Aug 13, 2024
787d77d
remove temp workaround
bdraco Aug 13, 2024
d5e0d93
bump
bdraco Aug 13, 2024
86ff51a
fix brand
bdraco Aug 13, 2024
1a2b858
7.1.3
bdraco Aug 13, 2024
4e3b819
override
bdraco Aug 13, 2024
c3e2010
override
bdraco Aug 13, 2024
4897533
override
bdraco Aug 13, 2024
e82d259
override
bdraco Aug 13, 2024
a50e639
split
bdraco Aug 13, 2024
76fda13
split
bdraco Aug 13, 2024
8fb58d6
preen
bdraco Aug 13, 2024
abcd290
bump to 8.0.0
bdraco Aug 13, 2024
277ccf8
bump
bdraco Aug 13, 2024
b73b2d8
Bump yalexs to 8.0.1
bdraco Aug 13, 2024
6c2f84d
fixes
bdraco Aug 13, 2024
3e4cf6f
fix
bdraco Aug 13, 2024
90708d1
Merge branch 'august_801' into yale_august_split_oauth
bdraco Aug 13, 2024
93c9673
merge
bdraco Aug 13, 2024
6dcd347
Merge remote-tracking branch 'upstream/dev' into yale_august_split_oauth
bdraco Aug 13, 2024
4a6ab04
Merge branch 'yale_august_split' into yale_august_split_oauth
bdraco Aug 13, 2024
653991f
bump
bdraco Aug 13, 2024
cb1f647
Merge branch 'yale_august_split' into yale_august_split_oauth
bdraco Aug 13, 2024
030d88c
Merge branch 'yale_august_split' into yale_august_split_oauth
bdraco Aug 20, 2024
8be883f
handle more in the lib
bdraco Aug 20, 2024
e6dfe0d
fix reauth
bdraco Aug 20, 2024
a7c56a2
debug
bdraco Aug 20, 2024
16a85cd
debug
bdraco Aug 20, 2024
25cc319
tweak
bdraco Aug 20, 2024
594a621
fix
bdraco Aug 20, 2024
a0a4563
bump
bdraco Aug 20, 2024
0c72b6d
cleanup
bdraco Aug 20, 2024
c64aac9
exc
bdraco Aug 20, 2024
7569e4d
one more
bdraco Aug 20, 2024
75a76b7
bump
bdraco Aug 20, 2024
eb226b6
Merge branch 'yale_august_split' into yale_august_split_oauth
bdraco Aug 20, 2024
7117774
Merge branch 'yale_august_split' into yale_august_split_oauth
bdraco Aug 23, 2024
90ba32a
convert tests to oauth
bdraco Aug 23, 2024
981a626
convert tests to oauth
bdraco Aug 23, 2024
ff86304
rework mocks
bdraco Aug 23, 2024
f836781
cleanup
bdraco Aug 23, 2024
8d20bee
remove tests that are not used for oauth
bdraco Aug 23, 2024
ac5f6bf
remove tests that are not used for oauth
bdraco Aug 23, 2024
3513a27
cloud is not needed, was only for accountlink testing
bdraco Aug 23, 2024
cee6241
cleanup unused
bdraco Aug 23, 2024
fcb3a47
split it a bit more
bdraco Aug 23, 2024
bd7972f
switch to user step
bdraco Aug 23, 2024
07de765
cleanup
bdraco Aug 23, 2024
643084a
cleanup
bdraco Aug 23, 2024
6f4883b
remove unused test path
bdraco Aug 23, 2024
4bb6fd7
remove unused test paths
bdraco Aug 23, 2024
31fb977
config flow tests
bdraco Aug 24, 2024
c22b2cb
fix missing cover
bdraco Aug 24, 2024
e5c98ef
strings
bdraco Aug 24, 2024
ec455bc
make pylint happy
bdraco Aug 24, 2024
3746093
cleanup
bdraco Aug 24, 2024
1ccac80
reduce
bdraco Aug 24, 2024
7b1e155
reduce
bdraco Aug 24, 2024
40d6e1b
Update tests/components/yale/mocks.py
bdraco Aug 24, 2024
7069423
preen
bdraco Aug 24, 2024
26e2013
autouse
bdraco Aug 24, 2024
932538e
cleanup
bdraco Aug 24, 2024
061361c
patch async_setup_entry in a fixture
bdraco Aug 24, 2024
03c0ceb
Merge branch 'yale_august_split' into yale_august_split_oauth
bdraco Aug 24, 2024
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
4 changes: 0 additions & 4 deletions homeassistant/components/august/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"codeowners": ["@bdraco"],
"config_flow": true,
"dhcp": [
{
"hostname": "yale-connect-plus",
"macaddress": "00177A*"
},
{
"hostname": "connect",
"macaddress": "D86162*"
Expand Down
18 changes: 13 additions & 5 deletions homeassistant/components/yale/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@
from typing import cast

from aiohttp import ClientResponseError
from yalexs.exceptions import AugustApiAIOHTTPError
from yalexs.const import Brand
from yalexs.exceptions import YaleApiError
from yalexs.manager.const import CONF_BRAND
from yalexs.manager.exceptions import CannotConnect, InvalidAuth, RequireValidation
from yalexs.manager.gateway import Config as YaleXSConfig

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EVENT_HOMEASSISTANT_STOP
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers import config_entry_oauth2_flow, device_registry as dr

from .const import DOMAIN, PLATFORMS
from .data import YaleData
Expand All @@ -27,14 +29,20 @@
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Set up yale from a config entry."""
session = async_create_yale_clientsession(hass)
yale_gateway = YaleGateway(Path(hass.config.config_dir), session)
implementation = (
await config_entry_oauth2_flow.async_get_config_entry_implementation(
hass, entry
)
)
oauth_session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
yale_gateway = YaleGateway(Path(hass.config.config_dir), session, oauth_session)
try:
await async_setup_yale(hass, entry, yale_gateway)
except (RequireValidation, InvalidAuth) as err:
raise ConfigEntryAuthFailed from err
except TimeoutError as err:
raise ConfigEntryNotReady("Timed out connecting to yale api") from err
except (AugustApiAIOHTTPError, ClientResponseError, CannotConnect) as err:
except (YaleApiError, ClientResponseError, CannotConnect) as err:
raise ConfigEntryNotReady from err
await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS)
return True
Expand All @@ -50,7 +58,7 @@ async def async_setup_yale(
) -> None:
"""Set up the yale component."""
config = cast(YaleXSConfig, entry.data)
await yale_gateway.async_setup(config)
await yale_gateway.async_setup({**config, CONF_BRAND: Brand.YALE_GLOBAL})
await yale_gateway.async_authenticate()
await yale_gateway.async_refresh_access_token_if_needed()
data = entry.runtime_data = YaleData(hass, yale_gateway)
Expand Down
15 changes: 15 additions & 0 deletions homeassistant/components/yale/application_credentials.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""application_credentials platform the yale integration."""

from homeassistant.components.application_credentials import AuthorizationServer
from homeassistant.core import HomeAssistant

OAUTH2_AUTHORIZE = "https://oauth.aaecosystem.com/authorize"
OAUTH2_TOKEN = "https://oauth.aaecosystem.com/access_token"


async def async_get_authorization_server(hass: HomeAssistant) -> AuthorizationServer:
"""Return authorization server."""
return AuthorizationServer(
authorize_url=OAUTH2_AUTHORIZE,
token_url=OAUTH2_TOKEN,
)
Loading
Loading