Skip to content

Commit ff98625

Browse files
authored
feat: ConfigFlow to show OTP Factor Type (Email/SMS) (#270)
1 parent 0d00b4a commit ff98625

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

custom_components/iec/config_flow.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
from iec_api.models.jwt import JWT
1919

2020
from .const import (
21-
CONF_TOTP_SECRET,
22-
DOMAIN,
23-
CONF_USER_ID,
24-
CONF_BP_NUMBER,
2521
CONF_AVAILABLE_CONTRACTS,
22+
CONF_BP_NUMBER,
2623
CONF_SELECTED_CONTRACTS,
24+
CONF_TOTP_SECRET,
25+
CONF_USER_ID,
26+
DOMAIN,
2727
)
2828

2929
_LOGGER = logging.getLogger(__name__)
@@ -150,11 +150,12 @@ async def async_step_mfa(
150150
schema = {}
151151

152152
schema[vol.Required(CONF_TOTP_SECRET)] = str
153-
await client.login_with_id()
153+
otp_type = await client.login_with_id()
154154

155155
return self.async_show_form(
156156
step_id="mfa",
157157
data_schema=vol.Schema(schema),
158+
description_placeholders={"otp_type": otp_type},
158159
errors=errors,
159160
)
160161

@@ -240,7 +241,7 @@ async def async_step_reauth_confirm(
240241
)
241242
client = self.client
242243

243-
await client.login_with_id()
244+
otp_type = await client.login_with_id()
244245

245246
schema = {
246247
vol.Required(CONF_USER_ID): self.reauth_entry.data[CONF_USER_ID],
@@ -249,6 +250,7 @@ async def async_step_reauth_confirm(
249250

250251
return self.async_show_form(
251252
step_id="reauth_confirm",
253+
description_placeholders={"otp_type": otp_type},
252254
data_schema=vol.Schema(schema),
253255
errors=errors,
254256
)

custom_components/iec/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
)
4444
CONF_USER_ID = "user_id"
4545
CONF_TOTP_SECRET = "totp_secret"
46+
CONF_TOTP_TYPE = "otp_type"
4647
CONF_BP_NUMBER = "bp_number"
4748
CONF_SELECTED_CONTRACTS = "selected_contracts"
4849
CONF_AVAILABLE_CONTRACTS = "contracts"

custom_components/iec/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88
"iot_class": "cloud_polling",
99
"issue_tracker": "https://github.com/guykh/iec-custom-component/issues",
1010
"loggers": ["iec_api"],
11-
"requirements": ["iec-api==0.4.11"],
11+
"requirements": ["iec-api==0.4.12"],
1212
"version": "0.0.1"
1313
}

custom_components/iec/translations/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
},
7878
"mfa": {
7979
"title": "OTP",
80-
"description": "Enter your One Time Password (OTP)",
80+
"description": "Enter your One Time Password (OTP) sent to your {otp_type}",
8181
"data": {
8282
"totp_secret": "e.g. 123456"
8383
}
@@ -88,6 +88,7 @@
8888
},
8989
"reauth_confirm": {
9090
"title": "[%key:common::config_flow::title::reauth%]",
91+
"description": "Enter your One Time Password (OTP) send to your {otp_type}",
9192
"data": {
9293
"user_id": "User ID",
9394
"totp_secret": "e.g. 123456"

custom_components/iec/translations/he.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
},
8181
"mfa": {
8282
"title": "OTP",
83-
"description": "הכניסו את הקוד החד-פעמי שנשלח אליכם (OTP)",
83+
"description": "הכניסו את הקוד החד-פעמי שנשלח אליכם (OTP) שנשלח ל-{otp_type}",
8484
"data": {
8585
"totp_secret": "לדוג' 123456"
8686
}
@@ -91,6 +91,7 @@
9191
},
9292
"reauth_confirm": {
9393
"title": "[%key:common::config_flow::title::reauth%]",
94+
"description": "הכניסו את הקוד החד-פעמי שנשלח אליכם (OTP) שנשלח ל-{otp_type}",
9495
"data": {
9596
"user_id": "מזהה לקוח",
9697
"totp_secret": "לדוג' 123456"

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
colorlog>=6.8.2
22
homeassistant==2024.2.0
3-
iec-api==0.4.11
3+
iec-api==0.4.12
44
pip>=21.0
55
ruff>=0.5.6

0 commit comments

Comments
 (0)