Support cloudhooks in Withings (#100916)
* Support cloudhooks in Withings * Support cloudhooks in Withings * Support cloudhooks in Withings * Remove strings
This commit is contained in:
parent
42b006a108
commit
0f95de997f
15 changed files with 421 additions and 189 deletions
|
@ -5,13 +5,11 @@ from collections.abc import Mapping
|
|||
import logging
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
from withings_api.common import AuthScope
|
||||
|
||||
from homeassistant.components.webhook import async_generate_id
|
||||
from homeassistant.config_entries import ConfigEntry, OptionsFlowWithConfigEntry
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_TOKEN, CONF_WEBHOOK_ID
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
from homeassistant.helpers import config_entry_oauth2_flow
|
||||
|
||||
|
@ -27,14 +25,6 @@ class WithingsFlowHandler(
|
|||
|
||||
reauth_entry: ConfigEntry | None = None
|
||||
|
||||
@staticmethod
|
||||
@callback
|
||||
def async_get_options_flow(
|
||||
config_entry: ConfigEntry,
|
||||
) -> WithingsOptionsFlowHandler:
|
||||
"""Get the options flow for this handler."""
|
||||
return WithingsOptionsFlowHandler(config_entry)
|
||||
|
||||
@property
|
||||
def logger(self) -> logging.Logger:
|
||||
"""Return logger."""
|
||||
|
@ -83,27 +73,9 @@ class WithingsFlowHandler(
|
|||
)
|
||||
|
||||
if self.reauth_entry.unique_id == user_id:
|
||||
self.hass.config_entries.async_update_entry(self.reauth_entry, data=data)
|
||||
self.hass.config_entries.async_update_entry(
|
||||
self.reauth_entry, data={**self.reauth_entry.data, **data}
|
||||
)
|
||||
return self.async_abort(reason="reauth_successful")
|
||||
|
||||
return self.async_abort(reason="wrong_account")
|
||||
|
||||
|
||||
class WithingsOptionsFlowHandler(OptionsFlowWithConfigEntry):
|
||||
"""Withings Options flow handler."""
|
||||
|
||||
async def async_step_init(
|
||||
self, user_input: dict[str, Any] | None = None
|
||||
) -> FlowResult:
|
||||
"""Initialize form."""
|
||||
if user_input is not None:
|
||||
return self.async_create_entry(
|
||||
data=user_input,
|
||||
)
|
||||
return self.async_show_form(
|
||||
step_id="init",
|
||||
data_schema=self.add_suggested_values_to_schema(
|
||||
vol.Schema({vol.Required(CONF_USE_WEBHOOK): bool}),
|
||||
self.options,
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue