27 lines
1015 B
Python
27 lines
1015 B
Python
from homeassistant import config_entries
|
|
import voluptuous as vol
|
|
import homeassistant.helpers.config_validation as cv
|
|
from .const import DOMAIN, CONF_PHONE_NUMBER, CONF_ACCOUNT_NAME
|
|
|
|
class WhatsAppBridgeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|
"""Handle a config flow for WhatsApp Bridge."""
|
|
VERSION = 1
|
|
|
|
async def async_step_user(self, user_input=None):
|
|
"""Erster Schritt wenn man auf 'Hinzufügen' klickt."""
|
|
errors = {}
|
|
if user_input is not None:
|
|
# Wir nutzen den Namen als Titel des Eintrags
|
|
return self.async_create_entry(
|
|
title=user_input[CONF_ACCOUNT_NAME],
|
|
data=user_input
|
|
)
|
|
|
|
return self.async_show_form(
|
|
step_id="user",
|
|
data_schema=vol.Schema({
|
|
vol.Required(CONF_ACCOUNT_NAME, default="Max Mustermann"): str,
|
|
vol.Required(CONF_PHONE_NUMBER, default="491701234567"): str,
|
|
}),
|
|
errors=errors,
|
|
) |