def _prepare_transition(self, is_on=None, **kwargs):
<EOL>dest_state = kwargs.copy()<EOL>if is_on is not None:<EOL><INDENT>if is_on and not self.is_on:<EOL><INDENT>if '<STR_LIT>' not in kwargs or kwargs['<STR_LIT>'] is None:<EOL><INDENT>dest_state['<STR_LIT>'] = self.brightness<EOL><DEDENT>self.set(brightness=<NUM_LIT:0>, cancel_transition=False)<EOL><DEDENT>elif not is_on and self.is_on:<EOL><INDENT>dest_state['<STR_LIT>'] = <NUM_LIT:0><EOL><DEDENT><DEDENT>return dest_state<EOL>
Perform pre-transition tasks and construct the destination state.

:param is_on: The on-off state to transition to.
:param kwargs: The state to transition to.
:return: The destination state of the transition.