async def setup_lights(hass: HomeAssistant, with_group: bool = False):
    """Set up 3 light entities using the 'template' platform."""
    n = 3 if not with_group else 5  # last 2 will be put in a group
    template_lights = {
        f"light_{i}": {
            "unique_id": f"light_{i}",
            "friendly_name": f"light_{i}",
            "turn_on": None,
            "turn_off": None,
            "set_level": None,
            "set_temperature": None,
            "set_color": None,
        }
        for i in range(1, n + 1)
    }
    template_lights["light_3"]["supports_transition_template"] = True
    platforms = [{"platform": "template", "lights": template_lights}]

    if with_group:
        platforms.append(
            {
                "platform": "group",
                "entities": ["light.light_4", "light.light_5"],
                "name": "Light Group",
                "unique_id": "light_group",
                "all": "false",
            },
        )

    await async_setup_component(
        hass,
        LIGHT_DOMAIN,
        {LIGHT_DOMAIN: platforms},
    )
    await hass.async_block_till_done()

    if with_group:
        state = hass.states.get("light.light_group")
        assert state.attributes["entity_id"] == ["light.light_4", "light.light_5"]

    platform = async_get_platforms(hass, "template")
    lights = list(platform[0].entities.values())

    await lights[0].async_turn_on()
    await lights[1].async_turn_on()

    for light in lights:
        light._attr_brightness = 255
        light._attr_color_temp = 250

    assert all(hass.states.get(light.entity_id) is not None for light in lights)
    return lights
Set up 3 light entities using the 'template' platform.
tests/test_switch.py