Skip to content

Commit 4a5dc8c

Browse files
authored
Add labels to selector in AndroidTV config flow (#155660)
1 parent 52a7515 commit 4a5dc8c

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

homeassistant/components/androidtv/config_flow.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
CONF_TURN_OFF_COMMAND,
4040
CONF_TURN_ON_COMMAND,
4141
DEFAULT_ADB_SERVER_PORT,
42-
DEFAULT_DEVICE_CLASS,
4342
DEFAULT_EXCLUDE_UNNAMED_APPS,
4443
DEFAULT_GET_SOURCES,
4544
DEFAULT_PORT,
4645
DEFAULT_SCREENCAP_INTERVAL,
46+
DEVICE_AUTO,
4747
DEVICE_CLASSES,
4848
DOMAIN,
4949
PROP_ETHMAC,
@@ -89,8 +89,14 @@ def _show_setup_form(
8989
data_schema = vol.Schema(
9090
{
9191
vol.Required(CONF_HOST, default=host): str,
92-
vol.Required(CONF_DEVICE_CLASS, default=DEFAULT_DEVICE_CLASS): vol.In(
93-
DEVICE_CLASSES
92+
vol.Required(CONF_DEVICE_CLASS, default=DEVICE_AUTO): SelectSelector(
93+
SelectSelectorConfig(
94+
options=[
95+
SelectOptionDict(value=k, label=v)
96+
for k, v in DEVICE_CLASSES.items()
97+
],
98+
translation_key="device_class",
99+
)
94100
),
95101
vol.Required(CONF_PORT, default=DEFAULT_PORT): cv.port,
96102
},

homeassistant/components/androidtv/const.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@
1515
CONF_TURN_ON_COMMAND = "turn_on_command"
1616

1717
DEFAULT_ADB_SERVER_PORT = 5037
18-
DEFAULT_DEVICE_CLASS = "auto"
1918
DEFAULT_EXCLUDE_UNNAMED_APPS = False
2019
DEFAULT_GET_SOURCES = True
2120
DEFAULT_PORT = 5555
2221
DEFAULT_SCREENCAP_INTERVAL = 5
2322

23+
DEVICE_AUTO = "auto"
2424
DEVICE_ANDROIDTV = "androidtv"
2525
DEVICE_FIRETV = "firetv"
26-
DEVICE_CLASSES = [DEFAULT_DEVICE_CLASS, DEVICE_ANDROIDTV, DEVICE_FIRETV]
26+
DEVICE_CLASSES = {
27+
DEVICE_AUTO: "auto",
28+
DEVICE_ANDROIDTV: "Android TV",
29+
DEVICE_FIRETV: "Fire TV",
30+
}
2731

2832
PROP_ETHMAC = "ethmac"
2933
PROP_SERIALNO = "serialno"

homeassistant/components/androidtv/strings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@
6565
}
6666
}
6767
},
68+
"selector": {
69+
"device_class": {
70+
"options": {
71+
"auto": "Auto-detect device type"
72+
}
73+
}
74+
},
6875
"services": {
6976
"adb_command": {
7077
"description": "Sends an ADB command to an Android / Fire TV device.",

0 commit comments

Comments
 (0)