From 66f43ebdc53541ce5e2a1b3969b254606ef9d063 Mon Sep 17 00:00:00 2001 From: Joakim Plate Date: Mon, 9 Oct 2023 19:52:24 +0200 Subject: [PATCH] Describe notification option (philip_js) (#101715) --- .../components/philips_js/config_flow.py | 43 +++++++------------ .../components/philips_js/strings.json | 5 ++- 2 files changed, 20 insertions(+), 28 deletions(-) diff --git a/homeassistant/components/philips_js/config_flow.py b/homeassistant/components/philips_js/config_flow.py index 9b7e52c2119..d1cd3e7b1a5 100644 --- a/homeassistant/components/philips_js/config_flow.py +++ b/homeassistant/components/philips_js/config_flow.py @@ -17,6 +17,11 @@ from homeassistant.const import ( CONF_USERNAME, ) from homeassistant.data_entry_flow import FlowResult +from homeassistant.helpers import selector +from homeassistant.helpers.schema_config_entry_flow import ( + SchemaFlowFormStep, + SchemaOptionsFlowHandler, +) from . import LOGGER from .const import CONF_ALLOW_NOTIFY, CONF_SYSTEM, CONST_APP_ID, CONST_APP_NAME, DOMAIN @@ -33,6 +38,15 @@ USER_SCHEMA = vol.Schema( } ) +OPTIONS_SCHEMA = vol.Schema( + { + vol.Optional(CONF_ALLOW_NOTIFY, default=False): selector.BooleanSelector(), + } +) +OPTIONS_FLOW = { + "init": SchemaFlowFormStep(OPTIONS_SCHEMA), +} + async def _validate_input( hass: core.HomeAssistant, host: str, api_version: int @@ -176,31 +190,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): @core.callback def async_get_options_flow( config_entry: config_entries.ConfigEntry, - ) -> OptionsFlowHandler: + ) -> SchemaOptionsFlowHandler: """Get the options flow for this handler.""" - return OptionsFlowHandler(config_entry) - - -class OptionsFlowHandler(config_entries.OptionsFlow): - """Handle a option flow for AEMET.""" - - def __init__(self, config_entry: config_entries.ConfigEntry) -> None: - """Initialize options flow.""" - self.config_entry = config_entry - - async def async_step_init( - self, user_input: dict[str, Any] | None = None - ) -> FlowResult: - """Handle options flow.""" - if user_input is not None: - return self.async_create_entry(title="", data=user_input) - - data_schema = vol.Schema( - { - vol.Required( - CONF_ALLOW_NOTIFY, - default=self.config_entry.options.get(CONF_ALLOW_NOTIFY), - ): bool, - } - ) - return self.async_show_form(step_id="init", data_schema=data_schema) + return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW) diff --git a/homeassistant/components/philips_js/strings.json b/homeassistant/components/philips_js/strings.json index a260d42feda..19228e906d9 100644 --- a/homeassistant/components/philips_js/strings.json +++ b/homeassistant/components/philips_js/strings.json @@ -30,7 +30,10 @@ "step": { "init": { "data": { - "allow_notify": "Allow usage of data notification service." + "allow_notify": "Allow notification service" + }, + "data_description": { + "allow_notify": "Allow the usage of data notification service on TV instead of periodic polling. This allow faster reaction to state changes on the TV, however, some TV's will stop responding when this activated due to firmware bugs." } } }