mirror of
https://github.com/Matysh/houseplan-card
synced 2026-07-31 08:28:31 +00:00
- entry.runtime_data (HouseplanData in store.py) instead of hass.data; WS answers not_ready without a loaded entry - test-before-setup (ConfigEntryNotReady), async_unload_entry, async_remove_entry (Lovelace resource cleanup), single_config_entry in manifest - Store minor_version + migration hook; diagnostics.py (redacted); repairs (broken_plan issues, en/ru); system_health.py; strings.json - quality_scale.yaml self-assessment; HA-harness tests (config flow, WS, upload) in CI on py3.13; CI backend job updated
40 lines
1.2 KiB
Python
Executable File
40 lines
1.2 KiB
Python
Executable File
"""Config flow: a single entry with no parameters."""
|
|
from __future__ import annotations
|
|
|
|
import voluptuous as vol
|
|
|
|
from homeassistant import config_entries
|
|
|
|
from .const import CONF_ADMIN_ONLY, DOMAIN
|
|
|
|
|
|
class HouseplanConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|
"""One-step setup."""
|
|
|
|
VERSION = 1
|
|
|
|
async def async_step_user(self, user_input=None):
|
|
if user_input is not None:
|
|
return self.async_create_entry(title="House Plan", data={}, options=user_input)
|
|
return self.async_show_form(
|
|
step_id="user",
|
|
data_schema=vol.Schema({vol.Optional(CONF_ADMIN_ONLY, default=False): bool}),
|
|
)
|
|
|
|
@staticmethod
|
|
def async_get_options_flow(config_entry):
|
|
return HouseplanOptionsFlow()
|
|
|
|
|
|
class HouseplanOptionsFlow(config_entries.OptionsFlow):
|
|
"""Option: layout editing by administrators only."""
|
|
|
|
async def async_step_init(self, user_input=None):
|
|
if user_input is not None:
|
|
return self.async_create_entry(title="", data=user_input)
|
|
current = self.config_entry.options.get(CONF_ADMIN_ONLY, False)
|
|
return self.async_show_form(
|
|
step_id="init",
|
|
data_schema=vol.Schema({vol.Optional(CONF_ADMIN_ONLY, default=current): bool}),
|
|
)
|