Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
HomeAssistant
Core
Commits
cc0fb804
Unverified
Commit
cc0fb804
authored
2 months ago
by
Brynley McDonald
Committed by
GitHub
2 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix Flick Electric authentication (#134611)
parent
276806d3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
homeassistant/components/flick_electric/__init__.py
+14
-12
14 additions, 12 deletions
homeassistant/components/flick_electric/__init__.py
with
14 additions
and
12 deletions
homeassistant/components/flick_electric/__init__.py
+
14
−
12
View file @
cc0fb804
...
...
@@ -2,10 +2,11 @@
from
datetime
import
datetime
as
dt
import
logging
from
typing
import
Any
import
jwt
from
pyflick
import
FlickAPI
from
pyflick.authentication
import
Abstract
FlickAuth
from
pyflick.authentication
import
Simple
FlickAuth
from
pyflick.const
import
DEFAULT_CLIENT_ID
,
DEFAULT_CLIENT_SECRET
from
homeassistant.config_entries
import
ConfigEntry
...
...
@@ -93,16 +94,22 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) ->
return
True
class
HassFlickAuth
(
Abstract
FlickAuth
):
class
HassFlickAuth
(
Simple
FlickAuth
):
"""
Implementation of AbstractFlickAuth based on a Home Assistant entity config.
"""
def
__init__
(
self
,
hass
:
HomeAssistant
,
entry
:
ConfigEntry
)
->
None
:
def
__init__
(
self
,
hass
:
HomeAssistant
,
entry
:
Flick
ConfigEntry
)
->
None
:
"""
Flick authentication based on a Home Assistant entity config.
"""
super
().
__init__
(
aiohttp_client
.
async_get_clientsession
(
hass
))
super
().
__init__
(
username
=
entry
.
data
[
CONF_USERNAME
],
password
=
entry
.
data
[
CONF_PASSWORD
],
client_id
=
entry
.
data
.
get
(
CONF_CLIENT_ID
,
DEFAULT_CLIENT_ID
),
client_secret
=
entry
.
data
.
get
(
CONF_CLIENT_SECRET
,
DEFAULT_CLIENT_SECRET
),
websession
=
aiohttp_client
.
async_get_clientsession
(
hass
),
)
self
.
_entry
=
entry
self
.
_hass
=
hass
async
def
_get_entry_token
(
self
):
async
def
_get_entry_token
(
self
)
->
dict
[
str
,
Any
]
:
# No token saved, generate one
if
(
CONF_TOKEN_EXPIRY
not
in
self
.
_entry
.
data
...
...
@@ -119,13 +126,8 @@ class HassFlickAuth(AbstractFlickAuth):
async
def
_update_token
(
self
):
_LOGGER
.
debug
(
"
Fetching new access token
"
)
token
=
await
self
.
get_new_token
(
username
=
self
.
_entry
.
data
[
CONF_USERNAME
],
password
=
self
.
_entry
.
data
[
CONF_PASSWORD
],
client_id
=
self
.
_entry
.
data
.
get
(
CONF_CLIENT_ID
,
DEFAULT_CLIENT_ID
),
client_secret
=
self
.
_entry
.
data
.
get
(
CONF_CLIENT_SECRET
,
DEFAULT_CLIENT_SECRET
),
token
=
await
super
().
get_new_token
(
self
.
_username
,
self
.
_password
,
self
.
_client_id
,
self
.
_client_secret
)
_LOGGER
.
debug
(
"
New token: %s
"
,
token
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment