Make the context argument of async_create_group explicit

The other keyword-only arguments have no default and every call site
passes them explicitly, including the ones that are None. Drop the
default so a new caller has to decide what to attribute the group to.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQdoLT4SC1w5LUgDQA3vEq
This commit is contained in:
Claude
2026-08-19 09:02:46 +00:00
parent f046364d9d
commit 3eeef26626
7 changed files with 42 additions and 1 deletions
+1 -1
View File
@@ -232,7 +232,7 @@ class Group(Entity):
mode: bool | None,
object_id: str | None,
order: int | None,
context: Context | None = None,
context: Context | None,
) -> Group:
"""Initialize a group.
@@ -216,6 +216,7 @@ async def test_lights_turn_on_when_coming_home_after_sun_set_person(
mode=None,
object_id=None,
order=None,
context=None,
)
assert await async_setup_component(
+28
View File
@@ -161,6 +161,7 @@ async def test_setup_group_with_mixed_groupable_states(hass: HomeAssistant) -> N
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.async_block_till_done()
@@ -183,6 +184,7 @@ async def test_setup_group_with_a_non_existing_state(hass: HomeAssistant) -> Non
mode=None,
object_id=None,
order=None,
context=None,
)
assert grp.state == STATE_ON
@@ -204,6 +206,7 @@ async def test_setup_group_with_non_groupable_states(hass: HomeAssistant) -> Non
mode=None,
object_id=None,
order=None,
context=None,
)
assert grp.state is None
@@ -220,6 +223,7 @@ async def test_setup_empty_group(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
assert grp.state is None
@@ -241,6 +245,7 @@ async def test_monitor_group(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
# Test if group setup in our init mode is ok
@@ -267,6 +272,7 @@ async def test_group_turns_off_if_all_off(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.async_block_till_done()
@@ -293,6 +299,7 @@ async def test_group_turns_on_if_all_are_off_and_one_turns_on(
mode=None,
object_id=None,
order=None,
context=None,
)
# Turn one on
@@ -321,6 +328,7 @@ async def test_allgroup_stays_off_if_all_are_off_and_one_turns_on(
mode=True,
object_id=None,
order=None,
context=None,
)
# Turn one on
@@ -347,6 +355,7 @@ async def test_allgroup_turn_on_if_last_turns_on(hass: HomeAssistant) -> None:
mode=True,
object_id=None,
order=None,
context=None,
)
# Turn one on
@@ -373,6 +382,7 @@ async def test_expand_entity_ids(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
assert sorted(["light.ceiling", "light.bowl"]) == sorted(
@@ -398,6 +408,7 @@ async def test_expand_entity_ids_does_not_return_duplicates(
mode=None,
object_id=None,
order=None,
context=None,
)
assert sorted(
@@ -425,6 +436,7 @@ async def test_expand_entity_ids_recursive(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
assert sorted(["light.ceiling", "light.bowl"]) == sorted(
@@ -453,6 +465,7 @@ async def test_get_entity_ids(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
assert sorted(group.get_entity_ids(hass, test_group.entity_id)) == [
@@ -476,6 +489,7 @@ async def test_get_entity_ids_with_domain_filter(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
assert group.get_entity_ids(
@@ -513,6 +527,7 @@ async def test_group_being_init_before_first_tracked_state_is_set_to_on(
mode=None,
object_id=None,
order=None,
context=None,
)
hass.states.async_set("light.not_there_1", STATE_ON)
@@ -541,6 +556,7 @@ async def test_group_being_init_before_first_tracked_state_is_set_to_off(
mode=None,
object_id=None,
order=None,
context=None,
)
hass.states.async_set("light.not_there_1", STATE_OFF)
@@ -565,6 +581,7 @@ async def test_groups_get_unique_names(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
grp2 = await group.Group.async_create_group(
hass,
@@ -575,6 +592,7 @@ async def test_groups_get_unique_names(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
assert grp1.entity_id != grp2.entity_id
@@ -594,6 +612,7 @@ async def test_expand_entity_ids_expands_nested_groups(hass: HomeAssistant) -> N
mode=None,
object_id=None,
order=None,
context=None,
)
await group.Group.async_create_group(
hass,
@@ -604,6 +623,7 @@ async def test_expand_entity_ids_expands_nested_groups(hass: HomeAssistant) -> N
mode=None,
object_id=None,
order=None,
context=None,
)
await group.Group.async_create_group(
hass,
@@ -614,6 +634,7 @@ async def test_expand_entity_ids_expands_nested_groups(hass: HomeAssistant) -> N
mode=None,
object_id=None,
order=None,
context=None,
)
assert sorted(group.expand_entity_ids(hass, ["group.group_of_groups"])) == [
@@ -640,6 +661,7 @@ async def test_set_assumed_state_based_on_tracked(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
state = hass.states.get(test_group.entity_id)
@@ -679,6 +701,7 @@ async def test_group_updated_after_device_tracker_zone_change(
mode=None,
object_id=None,
order=None,
context=None,
)
hass.states.async_set("device_tracker.Adam", "cool_state_not_home")
@@ -705,6 +728,7 @@ async def test_is_on(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.async_block_till_done()
@@ -842,6 +866,7 @@ async def test_is_on_and_state_mixed_domains(
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.async_block_till_done()
@@ -885,6 +910,7 @@ async def test_reloading_groups(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.async_block_till_done()
@@ -962,6 +988,7 @@ async def test_setup(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
await group.Group.async_create_group(
hass,
@@ -972,6 +999,7 @@ async def test_setup(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.async_block_till_done()
@@ -302,6 +302,7 @@ async def test_set_config_parameter(
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.services.async_call(
DOMAIN,
@@ -800,6 +801,7 @@ async def test_bulk_set_config_parameters(
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.services.async_call(
DOMAIN,
@@ -943,6 +945,7 @@ async def test_refresh_value(
mode=None,
object_id=None,
order=None,
context=None,
)
client.async_send_command.return_value = {"result": 2}
await hass.services.async_call(
@@ -1075,6 +1078,7 @@ async def test_set_value(
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.services.async_call(
DOMAIN,
@@ -1385,6 +1389,7 @@ async def test_multicast_set_value(
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.services.async_call(
DOMAIN,
@@ -1760,6 +1765,7 @@ async def test_ping(
mode=None,
object_id=None,
order=None,
context=None,
)
await hass.services.async_call(
DOMAIN,
@@ -740,6 +740,7 @@ async def test_expand(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
info = render_to_info(
@@ -800,6 +801,7 @@ async def test_expand(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
info = render_to_info(
@@ -1301,6 +1303,7 @@ async def test_closest_function_home_vs_group_entity_id(hass: HomeAssistant) ->
mode=None,
object_id=None,
order=None,
context=None,
)
info = render_to_info(hass, '{{ closest("group.location_group").entity_id }}')
@@ -1338,6 +1341,7 @@ async def test_closest_function_home_vs_group_state(hass: HomeAssistant) -> None
mode=None,
object_id=None,
order=None,
context=None,
)
info = render_to_info(hass, '{{ closest("group.location_group").entity_id }}')
+1
View File
@@ -719,6 +719,7 @@ async def test_extract_entity_ids(hass: HomeAssistant) -> None:
mode=None,
object_id=None,
order=None,
context=None,
)
call = ServiceCall(hass, "light", "turn_on", {ATTR_ENTITY_ID: "light.Bowl"})
+1
View File
@@ -513,6 +513,7 @@ async def test_extract_referenced_entity_ids(
mode=None,
object_id=None,
order=None,
context=None,
)
target_selection = selection_class(selector_config)