Skip to content

Commit 332ced2

Browse files
Change state_to to selector of common values
1 parent 8583d7b commit 332ced2

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

custom_components/label_state/config_flow.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
"state",
3131
]
3232

33+
STATE_TO_UNAVAILABLE = "unavailable"
34+
STATE_TO_ON = "on"
35+
STATE_TO_OFF = "off"
36+
STATE_TO_OPTIONS = [STATE_TO_UNAVAILABLE, STATE_TO_ON, STATE_TO_OFF]
37+
3338

3439
OPTIONS_SCHEMA_NUMERIC_STATE = vol.Schema(
3540
{
@@ -50,7 +55,13 @@
5055
OPTIONS_SCHEMA_STATE = vol.Schema(
5156
{
5257
vol.Required(CONF_LABEL): selector.LabelSelector(),
53-
vol.Required(CONF_STATE_TO): selector.TextSelector(),
58+
vol.Required(CONF_STATE_TO): selector.SelectSelector(
59+
selector.SelectSelectorConfig(
60+
options=STATE_TO_OPTIONS,
61+
translation_key="state_to",
62+
custom_value=True,
63+
)
64+
),
5465
}
5566
)
5667

custom_components/label_state/translations/de.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,14 @@
5656
}
5757
}
5858
}
59+
},
60+
"selector": {
61+
"state_to": {
62+
"options": {
63+
"unavailable": "Unavailable",
64+
"on": "On",
65+
"off": "Off"
66+
}
67+
}
5968
}
6069
}

custom_components/label_state/translations/en.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,14 @@
5656
}
5757
}
5858
}
59+
},
60+
"selector": {
61+
"state_to": {
62+
"options": {
63+
"unavailable": "Unavailable",
64+
"on": "On",
65+
"off": "Off"
66+
}
67+
}
5968
}
6069
}

0 commit comments

Comments
 (0)