8000 Fix connection issues with withings API by switching to a maintained codebase by vangorra · Pull Request #27310 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix connection issues with withings API by switching to a maintained codebase #27310

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

Merged
merged 3 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 8 additions & 6 deletions homeassistant/components/withings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import re
import time

import nokia
import withings_api as withings
from oauthlib.oauth2.rfc6749.errors import MissingTokenError
from requests_oauthlib import TokenUpdated

Expand Down Expand Up @@ -68,7 +68,9 @@ class WithingsDataManager:

service_available = None

def __init__(self, hass: HomeAssistantType, profile: str, api: nokia.NokiaApi):
def __init__(
self, hass: HomeAssistantType, profile: str, api: withings.WithingsApi
):
"""Constructor."""
self._hass = hass
self._api = api
Expand Down Expand Up @@ -253,7 +255,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 = nokia.NokiaCredentials(
credentials = withings.WithingsCredentials(
entry_creds.get("access_token"),
entry_creds.get("token_expiry"),
entry_creds.get("token_type"),
Expand All @@ -266,7 +268,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 NokiaCredentials object
# Sanitizing the data as sometimes a WithingsCredentials object
# is passed through from the API.
cred_data = credentials_param
if not isinstance(credentials_param, dict):
Expand All @@ -275,8 +277,8 @@ def credentials_saver(credentials_param):
entry.data[const.CREDENTIALS] = cred_data
hass.config_entries.async_update_entry(entry, data={**entry.data})

_LOGGER.debug("Creating nokia api instance")
api = nokia.NokiaApi(
_LOGGER.debug("Creating withings api instance")
api = withings.WithingsApi(
credentials, refresh_cb=(lambda token: credentials_saver(api.credentials))
)

Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/withings/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Optional

import aiohttp
import nokia
import withings_api as withings
import voluptuous as vol

from homeassistant import config_entries, data_entry_flow
Expand Down Expand Up @@ -75,7 +75,7 @@ def get_auth_client(self, profile: str):
profile,
)

return nokia.NokiaAuth(
return withings.WithingsAuth(
client_id,
client_secret,
callback_uri,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/withings/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"config_flow": true,
"documentation": "https://www.home-assistant.io/components/withings",
"requirements": [
"nokia==1.2.0"
"withings-api==2.0.0b7"
],
"dependencies": [
"api",
Expand Down
6 changes: 3 additions & 3 deletions requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,6 @@ niko-home-control==0.2.1
# homeassistant.components.nilu
niluclient==0.1.2

# homeassistant.components.withings
nokia==1.2.0

# homeassistant.components.nederlandse_spoorwegen
nsapi==2.7.4

Expand Down Expand Up @@ -1966,6 +1963,9 @@ websockets==6.0
# homeassistant.components.wirelesstag
wirelesstagpy==0.4.0

# homeassistant.components.withings
withings-api==2.0.0b7

# homeassistant.components.wunderlist
wunderpy2==0.1.6

Expand Down
6 changes: 3 additions & 3 deletions requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,6 @@ minio==4.0.9
# homeassistant.components.ssdp
netdisco==2.6.0

# homeassistant.components.withings
nokia==1.2.0

# homeassistant.components.iqvia
# homeassistant.components.opencv
# homeassistant.components.tensorflow
Expand Down Expand Up @@ -424,6 +421,9 @@ vultr==0.1.2
# homeassistant.components.wake_on_lan
wakeonlan==1.1.6

# homeassistant.components.withings
withings-api==2.0.0b7

# homeassistant.components. 6D47 zeroconf
zeroconf==0.23.0

Expand Down
2 changes: 1 addition & 1 deletion script/gen_requirements_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
"mficlient",
"minio",
"netdisco",
"nokia",
"numpy",
"oauth2client",
"paho-mqtt",
Expand Down Expand Up @@ -174,6 +173,7 @@
"vultr",
"wakeonlan",
"warrant",
"withings-api",
"YesssSMS",
"zeroconf",
"zigpy-homeassistant",
Expand Down
12 changes: 6 additions & 6 deletions tests/components/withings/common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Common data for for the withings component tests."""
import time

import nokia
import withings_api as withings

import homeassistant.components.withings.const as const

Expand Down Expand Up @@ -92,7 +92,7 @@ def new_measure(type_str, value, unit):
}


def nokia_sleep_response(states):
def withings_sleep_response(states):
"""Create a sleep response based on states."""
data = []
for state in states:
Expand All @@ -104,10 +104,10 @@ def nokia_sleep_response(states):
)
)

return nokia.NokiaSleep(new_sleep_data("aa", data))
return withings.WithingsSleep(new_sleep_data("aa", data))


NOKIA_MEASURES_RESPONSE = nokia.NokiaMeasures(
WITHINGS_MEASURES_RESPONSE = withings.WithingsMeasures(
{
"updatetime": "",
"timezone": "",
Expand Down Expand Up @@ -174,7 +174,7 @@ def nokia_sleep_response(states):
)


NOKIA_SLEEP_RESPONSE = nokia_sleep_response(
WITHINGS_SLEEP_RESPONSE = withings_sleep_response(
[
const.MEASURE_TYPE_SLEEP_STATE_AWAKE,
const.MEASURE_TYPE_SLEEP_STATE_LIGHT,
Expand All @@ -183,7 +183,7 @@ def nokia_sleep_response(states):
]
)

NOKIA_SLEEP_SUMMARY_RESPONSE = nokia.NokiaSleepSummary(
WITHINGS_SLEEP_SUMMARY_RESPONSE = withings.WithingsSleepSummary(
{
"series": [
new_sleep_summary(
Expand Down
Loading
0