-
Notifications
You must be signed in to change notification settings - Fork 2
/
options.py
104 lines (95 loc) · 3.73 KB
/
options.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
import collections
import logging
import voluptuous as vol
from homeassistant import config_entries
from homeassistant.core import callback
from homeassistant.helpers import config_validation as cv
_LOGGER = logging.getLogger(__name__)
DOMAIN = "boi_exchange_rates"
class OptionsFlowHandler(config_entries.OptionsFlow):
"""Options flow for Bank of Israel Exchange Rates integration."""
def __init__(self, config_entry):
"""Initialize options flow."""
self.config_entry = config_entry
async def async_step_init(self, user_input=None):
"""Handle options flow."""
if user_input is not None:
return self.async_create_entry(title="", data=user_input)
currency_names = {
"USD": "US Dollar",
"GBP": "British Pound",
"JPY": "Japanese Yen 100 units",
"EUR": "Euro",
"AUD": "Australian Dollar",
"CAD": "Canadian Dollar",
"DKK": "Danish Krone",
"NOK": "Norwegian Krone",
"ZAR": "South African Rand",
"SEK": "Swedish Krona",
"CHF": "Swiss Franc",
"JOD": "Jordanian Dinar",
"LBP": "Lebanese Pound 10 units",
"EGP": "Egyptian Pound",
}
options_schema = vol.Schema(
{
vol.Optional(
"currencies",
default=list(self.config_entry.options.get("currencies", [])),
): cv.multi_select(
{
code: f"{name} ({code})"
for code, name in sorted(
[
("USD", "US Dollar"),
("GBP", "British Pound"),
("JPY", "Japanese Yen 100 units"),
("EUR", "Euro"),
("AUD", "Australian Dollar"),
("CAD", "Canadian Dollar"),
("DKK", "Danish Krone"),
("NOK", "Norwegian Krone"),
("ZAR", "South African Rand"),
("SEK", "Swedish Krona"),
("CHF", "Swiss Franc"),
("JOD", "Jordanian Dinar"),
("LBP", "Lebanese Pound 10 units"),
("EGP", "Egyptian Pound"),
]
)
}
),
}
)
return self.async_show_form(
step_id="init",
data_schema=options_schema,
description_placeholders={
"column1": "\n".join(
f"[ ] {name} ({code})" for code, name in sorted(
[
("USD", "US Dollar"),
("GBP", "British Pound"),
("JPY", "Japanese Yen 100 units"),
("EUR", "Euro"),
("AUD", "Australian Dollar"),
("CAD", "Canadian Dollar"),
("DKK", "Danish Krone"),
]
)
),
"column2": "\n".join(
f"[ ] {name} ({code})" for code, name in sorted(
[
("NOK", "Norwegian Krone"),
("ZAR", "South African Rand"),
("SEK", "Swedish Krona"),
("CHF", "Swiss Franc"),
("JOD", "Jordanian Dinar"),
("LBP", "Lebanese Pound 10 units"),
("EGP", "Egyptian Pound"),
]
)
),
},
)