async def test_adapt_until_sleep_and_rgb_colors(hass):
    """Test setting up the Adaptive Lighting switches with different timezones.

    Also test the (sleep) brightness and color temperature settings.
    """
    lat, long, timezone = (32.87336, -117.22743, "US/Pacific")
    await async_process_ha_core_config(
        hass,
        {"latitude": lat, "longitude": long, "time_zone": timezone, "country": "US"},
    )
    switch, lights = await setup_lights_and_switch(
        hass,
        {
            CONF_SUNRISE_TIME: datetime.time(SUNRISE.hour),
            CONF_SUNSET_TIME: datetime.time(SUNSET.hour),
            CONF_ADAPT_UNTIL_SLEEP: True,
            CONF_SLEEP_RGB_OR_COLOR_TEMP: "rgb_color",
        },
    )

    context = switch.create_context("test")  # needs to be passed to update method
    min_color_temp = switch._sun_light_settings.min_color_temp

    sunset = SUNSET.replace(tzinfo=dt_util.DEFAULT_TIME_ZONE).astimezone(dt_util.UTC)
    before_sunset = sunset - datetime.timedelta(hours=1)
    after_sunset = sunset + datetime.timedelta(hours=1)
    sunrise = SUNRISE.replace(tzinfo=dt_util.DEFAULT_TIME_ZONE).astimezone(dt_util.UTC)
    before_sunrise = sunrise - datetime.timedelta(hours=1)
    after_sunrise = sunrise + datetime.timedelta(hours=1)

    async def patch_time_and_update(time):
        with patch(
            "homeassistant.components.adaptive_lighting.color_and_brightness.utcnow",
            return_value=time,
        ):
            await switch._update_attrs_and_maybe_adapt_lights(context=context)
            await hass.async_block_till_done()

    # At sunset the brightness should be max and color_temp at the smallest value
    await patch_time_and_update(sunset)
    assert not switch._settings["force_rgb_color"]
    assert switch._settings[ATTR_BRIGHTNESS_PCT] == DEFAULT_MAX_BRIGHTNESS
    assert switch._settings["color_temp_kelvin"] == min_color_temp

    # One hour before sunset the brightness should be max and color_temp
    # not at the smallest value yet.
    await patch_time_and_update(before_sunset)
    assert not switch._settings["force_rgb_color"]
    assert switch._settings[ATTR_BRIGHTNESS_PCT] == DEFAULT_MAX_BRIGHTNESS
    assert switch._settings["color_temp_kelvin"] > min_color_temp
    assert "color_temp_kelvin" in switch.manager.last_service_data[ENTITY_LIGHT_1]

    # One hour after sunset the brightness should be down and use RGB
    await patch_time_and_update(after_sunset)
    assert switch._settings["force_rgb_color"]
    assert switch._settings[ATTR_BRIGHTNESS_PCT] < DEFAULT_MAX_BRIGHTNESS
    assert "rgb_color" in switch.manager.last_service_data[ENTITY_LIGHT_1]

    # At sunrise the brightness should be max and use Kelvin
    await patch_time_and_update(sunrise)
    assert switch._settings[ATTR_BRIGHTNESS_PCT] == DEFAULT_MAX_BRIGHTNESS
    assert switch._settings["color_temp_kelvin"] == min_color_temp
    assert "color_temp_kelvin" in switch.manager.last_service_data[ENTITY_LIGHT_1]

    # One hour before sunrise the brightness should smaller than max
    # and use RGB
    await patch_time_and_update(before_sunrise)
    assert switch._settings[ATTR_BRIGHTNESS_PCT] < DEFAULT_MAX_BRIGHTNESS
    assert "rgb_color" in switch.manager.last_service_data[ENTITY_LIGHT_1]

    # One hour after sunrise the brightness should be up and it should use Kelvin
    await patch_time_and_update(after_sunrise)
    assert switch._settings[ATTR_BRIGHTNESS_PCT] == DEFAULT_MAX_BRIGHTNESS
    assert switch._settings["color_temp_kelvin"] > min_color_temp
    assert "color_temp_kelvin" in switch.manager.last_service_data[ENTITY_LIGHT_1]

    # Turn on sleep mode which make the brightness and color_temp
    # deterministic regardless of the time
    await switch.sleep_mode_switch.async_turn_on()
    await switch._update_attrs_and_maybe_adapt_lights(context=context)
    assert switch._settings[ATTR_BRIGHTNESS_PCT] == DEFAULT_SLEEP_BRIGHTNESS
    assert switch._settings["rgb_color"] == DEFAULT_SLEEP_RGB_COLOR
Test setting up the Adaptive Lighting switches with different timezones.

    Also test the (sleep) brightness and color temperature settings.
    
tests/test_switch.py