Skip to content

Commit fe1ff45

Browse files
CFennerbieniu
andauthored
Add labels to selector in Brother config flow (#155659)
Co-authored-by: Maciej Bieniek <[email protected]>
1 parent ec25ead commit fe1ff45

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

homeassistant/components/brother/config_flow.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from homeassistant.core import HomeAssistant
1414
from homeassistant.data_entry_flow import section
1515
from homeassistant.exceptions import HomeAssistantError
16+
from homeassistant.helpers.selector import SelectSelector, SelectSelectorConfig
1617
from homeassistant.helpers.service_info.zeroconf import ZeroconfServiceInfo
1718
from homeassistant.util.network import is_host_valid
1819

@@ -21,14 +22,20 @@
2122
DEFAULT_COMMUNITY,
2223
DEFAULT_PORT,
2324
DOMAIN,
25+
PRINTER_TYPE_LASER,
2426
PRINTER_TYPES,
2527
SECTION_ADVANCED_SETTINGS,
2628
)
2729

2830
DATA_SCHEMA = vol.Schema(
2931
{
3032
vol.Required(CONF_HOST): str,
31-
vol.Optional(CONF_TYPE, default="laser"): vol.In(PRINTER_TYPES),
33+
vol.Required(CONF_TYPE, default=PRINTER_TYPE_LASER): SelectSelector(
34+
SelectSelectorConfig(
35+
options=PRINTER_TYPES,
36+
translation_key="printer_type",
37+
)
38+
),
3239
vol.Required(SECTION_ADVANCED_SETTINGS): section(
3340
vol.Schema(
3441
{
@@ -42,7 +49,12 @@
4249
)
4350
ZEROCONF_SCHEMA = vol.Schema(
4451
{
45-
vol.Optional(CONF_TYPE, default="laser"): vol.In(PRINTER_TYPES),
52+
vol.Required(CONF_TYPE, default=PRINTER_TYPE_LASER): SelectSelector(
53+
SelectSelectorConfig(
54+
options=PRINTER_TYPES,
55+
translation_key="printer_type",
56+
)
57+
),
4658
vol.Required(SECTION_ADVANCED_SETTINGS): section(
4759
vol.Schema(
4860
{

homeassistant/components/brother/const.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
DOMAIN: Final = "brother"
99

10-
PRINTER_TYPES: Final = ["laser", "ink"]
10+
PRINTER_TYPE_LASER = "laser"
11+
PRINTER_TYPE_INK = "ink"
12+
13+
PRINTER_TYPES: Final = [PRINTER_TYPE_LASER, PRINTER_TYPE_INK]
1114

1215
UPDATE_INTERVAL = timedelta(seconds=30)
1316

homeassistant/components/brother/strings.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
"user": {
3939
"data": {
4040
"host": "[%key:common::config_flow::data::host%]",
41-
"type": "Type of the printer"
41+
"type": "Printer type"
4242
},
4343
"data_description": {
4444
"host": "The hostname or IP address of the Brother printer to control.",
45-
"type": "Brother printer type: ink or laser."
45+
"type": "The type of the Brother printer."
4646
},
4747
"sections": {
4848
"advanced_settings": {
@@ -210,5 +210,13 @@
210210
"update_error": {
211211
"message": "An error occurred while retrieving data from the {device} printer: {error}"
212212
}
213+
},
214+
"selector": {
215+
"printer_type": {
216+
"options": {
217+
"ink": "ink",
218+
"laser": "laser"
219+
}
220+
}
213221
}
214222
}

0 commit comments

Comments
 (0)