Transition wrapper.

        Short-circuit transition as necessary.

        :param duration: Time to transition.
        :param color: Transition to this color.
        :param brightness: Transition to this brightness.
        :param temperature: Transition to this temperature.

def transition(self, duration,
                   color=None, brightness=None, temperature=None):
        """ Transition wrapper.

        Short-circuit transition as necessary.

        :param duration: Time to transition.
        :param color: Transition to this color.
        :param brightness: Transition to this brightness.
        :param temperature: Transition to this temperature.
        """
        if color and temperature is not None:
            raise ValueError("Cannot transition to color and temperature "
                             "simultaneously.")

        # Transition to white immediately.
        if color == RGB_WHITE:
            self.white()
        # Transition away from white immediately.
        elif self.color == RGB_WHITE and color is not None:
            self.color = color
        # Transition immediately if duration is zero.
        if duration == 0:
            if brightness is not None:
                self.brightness = brightness
            if color:
                self.color = color
            if temperature is not None:
                self.temperature = temperature
            return
        # Perform transition
        if color and color != self.color:
            self._transition(duration, brightness,
                             hue=hue_of_color(color),
                             saturation=saturation_of_color(color))
        elif temperature != self.temperature:
            self._transition(duration, brightness, temperature=temperature)
        elif brightness != self.brightness:
            self._transition(duration, brightness)