Add 'all' option to light/switch group config flow (#149671)

This commit is contained in:
karwosts
2025-08-13 03:34:58 -07:00
committed by GitHub
parent 51fbccd125
commit 7fba0ca2c0
3 changed files with 28 additions and 4 deletions

View File

@@ -146,6 +146,20 @@ async def light_switch_options_schema(
) )
LIGHT_CONFIG_SCHEMA = basic_group_config_schema("light").extend(
{
vol.Required(CONF_ALL, default=False): selector.BooleanSelector(),
}
)
SWITCH_CONFIG_SCHEMA = basic_group_config_schema("switch").extend(
{
vol.Required(CONF_ALL, default=False): selector.BooleanSelector(),
}
)
GROUP_TYPES = [ GROUP_TYPES = [
"binary_sensor", "binary_sensor",
"button", "button",
@@ -210,7 +224,7 @@ CONFIG_FLOW = {
validate_user_input=set_group_type("fan"), validate_user_input=set_group_type("fan"),
), ),
"light": SchemaFlowFormStep( "light": SchemaFlowFormStep(
basic_group_config_schema("light"), LIGHT_CONFIG_SCHEMA,
preview="group", preview="group",
validate_user_input=set_group_type("light"), validate_user_input=set_group_type("light"),
), ),
@@ -235,7 +249,7 @@ CONFIG_FLOW = {
validate_user_input=set_group_type("sensor"), validate_user_input=set_group_type("sensor"),
), ),
"switch": SchemaFlowFormStep( "switch": SchemaFlowFormStep(
basic_group_config_schema("switch"), SWITCH_CONFIG_SCHEMA,
preview="group", preview="group",
validate_user_input=set_group_type("switch"), validate_user_input=set_group_type("switch"),
), ),

View File

@@ -66,9 +66,13 @@
"light": { "light": {
"title": "[%key:component::group::config::step::user::title%]", "title": "[%key:component::group::config::step::user::title%]",
"data": { "data": {
"all": "[%key:component::group::config::step::binary_sensor::data::all%]",
"entities": "[%key:component::group::config::step::binary_sensor::data::entities%]", "entities": "[%key:component::group::config::step::binary_sensor::data::entities%]",
"hide_members": "[%key:component::group::config::step::binary_sensor::data::hide_members%]", "hide_members": "[%key:component::group::config::step::binary_sensor::data::hide_members%]",
"name": "[%key:common::config_flow::data::name%]" "name": "[%key:common::config_flow::data::name%]"
},
"data_description": {
"all": "[%key:component::group::config::step::binary_sensor::data_description::all%]"
} }
}, },
"lock": { "lock": {
@@ -115,9 +119,13 @@
"switch": { "switch": {
"title": "[%key:component::group::config::step::user::title%]", "title": "[%key:component::group::config::step::user::title%]",
"data": { "data": {
"all": "[%key:component::group::config::step::binary_sensor::data::all%]",
"entities": "[%key:component::group::config::step::binary_sensor::data::entities%]", "entities": "[%key:component::group::config::step::binary_sensor::data::entities%]",
"hide_members": "[%key:component::group::config::step::binary_sensor::data::hide_members%]", "hide_members": "[%key:component::group::config::step::binary_sensor::data::hide_members%]",
"name": "[%key:common::config_flow::data::name%]" "name": "[%key:common::config_flow::data::name%]"
},
"data_description": {
"all": "[%key:component::group::config::step::binary_sensor::data_description::all%]"
} }
} }
} }

View File

@@ -44,7 +44,8 @@ from tests.typing import WebSocketGenerator
{}, {},
), ),
("fan", "on", "on", {}, {}, {}, {}), ("fan", "on", "on", {}, {}, {}, {}),
("light", "on", "on", {}, {}, {}, {}), ("light", "on", "on", {}, {}, {"all": False}, {}),
("light", "on", "on", {}, {"all": True}, {"all": True}, {}),
("lock", "locked", "locked", {}, {}, {}, {}), ("lock", "locked", "locked", {}, {}, {}, {}),
("notify", STATE_UNKNOWN, "2021-01-01T23:59:59.123+00:00", {}, {}, {}, {}), ("notify", STATE_UNKNOWN, "2021-01-01T23:59:59.123+00:00", {}, {}, {}, {}),
("media_player", "on", "on", {}, {}, {}, {}), ("media_player", "on", "on", {}, {}, {}, {}),
@@ -57,7 +58,8 @@ from tests.typing import WebSocketGenerator
{"type": "sum"}, {"type": "sum"},
{}, {},
), ),
("switch", "on", "on", {}, {}, {}, {}), ("switch", "on", "on", {}, {}, {"all": False}, {}),
("switch", "on", "on", {}, {"all": True}, {"all": True}, {}),
], ],
) )
async def test_config_flow( async def test_config_flow(