def plot_brightness(inputs: dict[str, Any], sleep_mode: bool):
    """Plot the brightness over time for different modes."""
    # Define the time range for our simulation
    sun_linear = SunLightSettings(**inputs, brightness_mode="linear")
    sun_tanh = SunLightSettings(**inputs, brightness_mode="tanh")
    sun = SunLightSettings(**inputs, brightness_mode="default")
    # Calculate the brightness for each time in the time range for all modes
    dt_range = date_range(sun.timezone)
    time_range = [time_to_float(dt) for dt in dt_range]
    brightness_linear_values = [
        sun_linear.brightness_pct(dt, sleep_mode) for dt in dt_range
    ]
    brightness_tanh_values = [
        sun_tanh.brightness_pct(dt, sleep_mode) for dt in dt_range
    ]
    brightness_default_values = [sun.brightness_pct(dt, sleep_mode) for dt in dt_range]

    # Plot the brightness over time for both modes
    fig, ax = plt.subplots(figsize=(10, 6))
    ax.plot(time_range, brightness_linear_values, label="Linear Mode")
    ax.plot(time_range, brightness_tanh_values, label="Tanh Mode")
    ax.plot(time_range, brightness_default_values, label="Default Mode", c="C5")
    sunrise_time = sun.sun.sunrise(dt.date.today())
    sunset_time = sun.sun.sunset(dt.date.today())
    ax.vlines(
        time_to_float(sunrise_time),
        0,
        100,
        color="C2",
        label="Sunrise",
        linestyles="dashed",
    )
    ax.vlines(
        time_to_float(sunset_time),
        0,
        100,
        color="C3",
        label="Sunset",
        linestyles="dashed",
    )
    ax.set_xlim(0, 24)
    ax.set_xticks(np.arange(0, 25, 1))
    yticks = np.arange(0, 105, 5)
    ytick_labels = [f"{label:.0f}%" for label in yticks]
    ax.set_yticks(yticks, ytick_labels)
    ax.set_xlabel("Time (hours)")
    ax.set_ylabel("Brightness")
    ax.set_title("Brightness over Time for Different Modes")

    # Add text box
    textstr = "\n".join(
        (
            f"Sunrise Time = {sunrise_time.time()}",
            f"Sunset Time = {sunset_time.time()}",
            f"Max Brightness = {sun.max_brightness:.0f}%",
            f"Min Brightness = {sun.min_brightness:.0f}%",
            f"Time Light = {sun.brightness_mode_time_light}",
            f"Time Dark = {sun.brightness_mode_time_dark}",
        ),
    )

    ax.legend()

    ax.text(
        0.4,
        0.55,
        textstr,
        transform=ax.transAxes,
        fontsize=10,
        verticalalignment="center",
        bbox={"boxstyle": "round", "facecolor": "wheat", "alpha": 0.5},
    )
    ax.grid(visible=True)

    return fig
Plot the brightness over time for different modes.
webapp/app.py