Describe notification option (philip_js) (#101715)

This commit is contained in:
Joakim Plate 2023-10-09 19:52:24 +02:00 committed by GitHub
parent 84fe356782
commit 66f43ebdc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 28 deletions

View File

@ -17,6 +17,11 @@ from homeassistant.const import (
CONF_USERNAME, CONF_USERNAME,
) )
from homeassistant.data_entry_flow import FlowResult 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 . import LOGGER
from .const import CONF_ALLOW_NOTIFY, CONF_SYSTEM, CONST_APP_ID, CONST_APP_NAME, DOMAIN 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( async def _validate_input(
hass: core.HomeAssistant, host: str, api_version: int hass: core.HomeAssistant, host: str, api_version: int
@ -176,31 +190,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
@core.callback @core.callback
def async_get_options_flow( def async_get_options_flow(
config_entry: config_entries.ConfigEntry, config_entry: config_entries.ConfigEntry,
) -> OptionsFlowHandler: ) -> SchemaOptionsFlowHandler:
"""Get the options flow for this handler.""" """Get the options flow for this handler."""
return OptionsFlowHandler(config_entry) return SchemaOptionsFlowHandler(config_entry, OPTIONS_FLOW)
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)

View File

@ -30,7 +30,10 @@
"step": { "step": {
"init": { "init": {
"data": { "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."
} }
} }
} }