Revert "Fix connection issues with withings API by switching to a maintained codebase (#27310)" (#27385)
This reverts commit 071476343c.
This commit is contained in:
1 parent
d337b71725
commit
c188ecf79b
9 files changed
+117
-130
No files matched your search
@@ -4,7 +4,7 @@ import logging
|
||||
import re
|
||||
import time
|
||||
|
||||
import withings_api as withings
|
||||
import nokia
|
||||
from oauthlib.oauth2.rfc6749.errors import MissingTokenError
|
||||
from requests_oauthlib import TokenUpdated
|
||||
|
||||
@@ -68,9 +68,7 @@ class WithingsDataManager:
|
||||
|
||||
service_available = None
|
||||
|
||||
def __init__(
|
||||
self, hass: HomeAssistantType, profile: str, api: withings.WithingsApi
|
||||
):
|
||||
def __init__(self, hass: HomeAssistantType, profile: str, api: nokia.NokiaApi):
|
||||
"""Constructor."""
|
||||
self._hass = hass
|
||||
self._api = api
|
||||
@@ -255,7 +253,7 @@ def create_withings_data_manager(
|
||||
"""Set up the sensor config entry."""
|
||||
entry_creds = entry.data.get(const.CREDENTIALS) or {}
|
||||
profile = entry.data[const.PROFILE]
|
||||
credentials = withings.WithingsCredentials(
|
||||
credentials = nokia.NokiaCredentials(
|
||||
entry_creds.get("access_token"),
|
||||
entry_creds.get("token_expiry"),
|
||||
entry_creds.get("token_type"),
|
||||
@@ -268,7 +266,7 @@ def create_withings_data_manager(
|
||||
def credentials_saver(credentials_param):
|
||||
_LOGGER.debug("Saving updated credentials of type %s", type(credentials_param))
|
||||
|
||||
# Sanitizing the data as sometimes a WithingsCredentials object
|
||||
# Sanitizing the data as sometimes a NokiaCredentials object
|
||||
# is passed through from the API.
|
||||
cred_data = credentials_param
|
||||
if not isinstance(credentials_param, dict):
|
||||
@@ -277,8 +275,8 @@ def create_withings_data_manager(
|
||||
entry.data[const.CREDENTIALS] = cred_data
|
||||
hass.config_entries.async_update_entry(entry, data={**entry.data})
|
||||
|
||||
_LOGGER.debug("Creating withings api instance")
|
||||
api = withings.WithingsApi(
|
||||
_LOGGER.debug("Creating nokia api instance")
|
||||
api = nokia.NokiaApi(
|
||||
credentials, refresh_cb=(lambda token: credentials_saver(api.credentials))
|
||||
)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import logging
|
||||
from typing import Optional
|
||||
|
||||
import aiohttp
|
||||
import withings_api as withings
|
||||
import nokia
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
@@ -75,7 +75,7 @@ class WithingsFlowHandler(config_entries.ConfigFlow):
|
||||
profile,
|
||||
)
|
||||
|
||||
return withings.WithingsAuth(
|
||||
return nokia.NokiaAuth(
|
||||
client_id,
|
||||
client_secret,
|
||||
callback_uri,
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/withings",
|
||||
"requirements": [
|
||||
"withings-api==2.0.0b7"
|
||||
"nokia==1.2.0"
|
||||
],
|
||||
"dependencies": [
|
||||
"api",
|
||||
|
||||
Reference in new issue
Block a user