<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _gen_packet_setpower(self, sequence, power, fade):
 """ Generate "setpower" packet payload. """

        level = pack("<H", Power.BULB_OFF if power == 0 else Power.BULB_ON)
        duration = pack("<I", fade)

        # assemble payload
        payload = bytearray(level)
        payload.extend(duration)

        return self._gen_packet(sequence, PayloadType.SETPOWER2, payload)