Fix withings InvalidParamsException (#47975)

* Bump withings_api to 2.3.1 (fixes #47329)

* Fix NotifyAppli calls to be compatible with withings_api 2.3.1

* Fix errors with withings_api 2.2+ using pydantic

* Bump withings_api to 2.3.2
This commit is contained in:
Ron Heft 2021-03-16 12:15:22 -04:00 committed by GitHub
parent 0097169dd3
commit bbd98e196b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 10 deletions

View file

@ -4,12 +4,12 @@ Support for the Withings API.
For more details about this platform, please refer to the documentation at
"""
import asyncio
from typing import Optional, cast
from typing import Optional
from aiohttp.web import Request, Response
import voluptuous as vol
from withings_api import WithingsAuth
from withings_api.common import NotifyAppli, enum_or_raise
from withings_api.common import NotifyAppli
from homeassistant.components import webhook
from homeassistant.components.binary_sensor import DOMAIN as BINARY_SENSOR_DOMAIN
@ -195,9 +195,7 @@ async def async_webhook_handler(
return json_message_response("Parameter appli not provided", message_code=20)
try:
appli = cast(
NotifyAppli, enum_or_raise(int(params.getone("appli")), NotifyAppli)
)
appli = NotifyAppli(int(params.getone("appli")))
except ValueError:
return json_message_response("Invalid appli provided", message_code=21)

View file

@ -681,7 +681,7 @@ class DataManager:
)
# Determine what subscriptions need to be created.
ignored_applis = frozenset({NotifyAppli.USER})
ignored_applis = frozenset({NotifyAppli.USER, NotifyAppli.UNKNOWN})
to_add_applis = frozenset(
[
appli
@ -846,7 +846,7 @@ class DataManager:
data = serie.data
for field in GetSleepSummaryField:
raw_values[field].append(data._asdict()[field.value])
raw_values[field].append(dict(data)[field.value])
values: Dict[GetSleepSummaryField, float] = {}

View file

@ -3,7 +3,7 @@
"name": "Withings",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/withings",
"requirements": ["withings-api==2.1.6"],
"requirements": ["withings-api==2.3.2"],
"dependencies": ["http", "webhook"],
"codeowners": ["@vangorra"]
}

View file

@ -2311,7 +2311,7 @@ wiffi==1.0.1
wirelesstagpy==0.4.1
# homeassistant.components.withings
withings-api==2.1.6
withings-api==2.3.2
# homeassistant.components.wled
wled==0.4.4

View file

@ -1187,7 +1187,7 @@ watchdog==1.0.2
wiffi==1.0.1
# homeassistant.components.withings
withings-api==2.1.6
withings-api==2.3.2
# homeassistant.components.wled
wled==0.4.4