def prev_and_next_events(self, dt: datetime.datetime) -> list[tuple[str, float]]:
        """Get the previous and next sun event."""
        events = [
            event
            for days in [-1, 0, 1]
            for event in self.sun_events(dt + timedelta(days=days))
        ]
        events = sorted(events, key=lambda x: x[1])
        i_now = bisect.bisect([ts for _, ts in events], dt.timestamp())
        return events[i_now - 1 : i_now + 1]
Get the previous and next sun event.
custom_components/adaptive_lighting/color_and_brightness.py