8000 Withings fix by vangorra · Pull Request #27404 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Withings fix #27404

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 6 commits into from
Oct 10, 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/integrations/withings",
"requirements": [
"nokia==1.2.0"
"withings-api==2.0.0b8"
],
"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 @@ -868,9 +868,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 @@ -1976,6 +1973,9 @@ websockets==6.0
# homeassistant.components.wirelesstag
wirelesstagpy==0.4.0

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

# homeassistant.components.wunderlist
wunderpy2==0.1.6 8000

Expand Down
6 changes: 3 additions & 3 deletions requirements_test_all.txt
< 6D40 tr class="js-expandable-line js-skip-tagsearch" data-position="">
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,6 @@ nessclient==0.9.15
# homeassistant.components.ssdp
netdisco==2.6.0

# homeassistant.components.withings
nokia==1.2.0

# homeassistant.components.nsw_fuel_station
nsw-fuel-api-client==1.0.10

Expand Down Expand Up @@ -618,6 +615,9 @@ watchdog==0.8.3
# homeassistant.components.webostv
websockets==6.0

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

# homeassistant.components.bluesound
# homeassistant.components.startca
# homeassistant.components.ted5000
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< 9E88 /span>(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