-
Notifications
You must be signed in to change notification settings - Fork 1
/
config_flow.py
46 lines (36 loc) · 1.39 KB
/
config_flow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
'''Config Flow for Home-Assistant integration'''
from __future__ import annotations
from typing import Any
from homeassistant import config_entries
from homeassistant.data_entry_flow import FlowResult
import voluptuous as vol
from .const import DOMAIN
class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
"""FuelWatch WA config flow class."""
# The schema version of the entries that it creates
# Home Assistant will call your migrate method if the version changes
VERSION = 1
def __init__(self):
"""Initialize the Config flow for FuelWatch WA"""
async def async_step_user(self, user_input: dict[str, Any] | None = None
) -> FlowResult:
'''Async User step for module'''
errors = {}
STEP_USER_DATA_SCHEMA= {
#vol.Required("suburb", default="Kelmscott"): str
vol.Required("suburb"): str,
vol.Required("product"): int,
vol.Required("day", default="today"): str
}
if user_input is not None:
# Validate User input.
# TODO: add in validations
valid = True
if valid:
return self.async_create_entry(
title="FuelWatchWA",
data=user_input
)
return self.async_show_form(
step_id="user", data_schema=vol.Schema(STEP_USER_DATA_SCHEMA), errors=errors
)